REST Calls and MDS

SharePoint 2013 introduces MDS, or Minimal Download Strategy, as a way to increase performance of various types of SharePoint sites (basically, non-publishing sites.) It’s turned on for quite a few site templates out of the box so it’s important to understand how it works. I won’t go into it here since others cover it well, but review the links at the bottom of this post if you’re interested.

When developing a custom master page, there’s a new control that you’ll need to be concerned with due to MDS called AjaxDelta. This control is used to tell MDS which controls or content that call into SharePoint require the user to be authenticated and authorized. Any content outside of an AjaxDelta control is treated anonymously. This may bite you if you forget and start moving controls around. An example of that can be found here.

If you haven’t put two and two together yet based on the title of this post, you’ll need to also wrap your client side REST calls with an AjaxDelta control. Well, maybe. I was getting pretty good results without the AjaxDelta wrapper, until I did some testing using Windows XP and IE 8. On that platform, my REST calls were resulting in “Access is Denied” entries in ULS logs in an unauthenticated server call (as shown by a “Authentication Authorization” entry where IsAuthenticated=false.) Once I put the script inside an AjaxDelta control, the problem went away.

<SharePoint:AjaxDelta ID="DeltaCustomJS" Container="false" runat="server">
     <script type="text/javascript" src="/SiteAssets/CustomBranding/custom.js"></script>

As mentioned, this was only for WinXP and IE8 so perhaps there is a client setting that can be changed to fix the issue as well.

Here’s a good link on MDS, if you’re interested (if you read this far, you’re interested Smile):

Wictor Wilen – Introduction to MDS

3 thoughts on “REST Calls and MDS”

  1. Nate Green says:

    Hey Ryan…I believe 2013 Search uses MDS for the async calls it makes. When I look for AjaxDelta, I can’t find the object. Do you know if there is a search-specific ‘delta’ object I could add my own JS code on after an aync call runs, similar to ‘syncDeltaManager.add_endRequest(doSomething);’?

    1. Hey Nate, if you’re looking to tie into a search response through a display template take a look at AddPostRenderCallback. I’ve used that a few times to execute my custom code after items are returned from search.

  2. I don’t, but maybe post a question on Yammer or Stackoverflow. If you find out, please post back here the answer. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *