none
UserControl in AdditionalPageHead breaking Minimal Download Strategy (MDS) RRS feed

  • Question

  • I need to create a user control to display on every SharePoint page, but it is causing MDS to failover and reload the page on team sites. How do I decorate or program my class so that MDS keeps working, like https://msdn.microsoft.com/en-us/library/office/dn456543.aspx says it should?

    Here's a simple example. I created an empty SharePoint 2013 project as a farm solution and added a user control to it called CountdownControl.ascx and it's corresponding Elements.xml file, like so:

     <Control Id="AdditionalPageHead" Sequence="90" ControlSrc="~/_ControlTemplates/15/Countdown/CountdownControl.ascx" />

    Then I added an ASP.NET Label to the .ascx file, and then set the code-behind file like this:

    [assembly: Microsoft.SharePoint.WebControls.MdsCompliantAttribute(IsCompliant = true)]
    namespace Countdown.ControlTemplates.Countdown
    {
        [Microsoft.SharePoint.WebControls.MdsCompliant(true)]
        public partial class CountdownControl : UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                DateTime Christmas = new  DateTime(DateTime.Today.Year, 12, 25, 0, 0, 1);
                if (DateTime.Now.CompareTo(Christmas) > 0) Christmas = Christmas.AddYears(1);
                int daysLeft = (Christmas - DateTime.Now).Days;
                Label1.Text = "Only " + daysLeft.ToString() + " more " + (daysLeft == 1 ? "day" : "days") + " until Christmas!";
            }
        }
    }
    

    When I deploy this simple example to a team site it works...sort of. It adds a line at the top of the page of course, but pages in a team site (with the Minimal Download Strategy feature activated) now failover and cause the page to reload twice, the second time without the /start.aspx# in the URL. Slower, and with an annoying page flash.

    Showing the days left until Christmas isn't the real requirement, it just makes a good example. What else do I need to do to keep MDS happy with a user control?

    Monday, December 19, 2016 6:56 PM

Answers

  • Hi,

    I tested this in my local, custom AdditionalPageHead delegate control will break MDS, it should be by design action currently.

    Seems it’s out of MDS support as described picture below:

    But some others delegate controls works fine, for example: SuiteLinksDelegate/ PromotedActions

    I would suggest not custom AdditionalPageHead delegate control currently.

    Best Regards,

    Lee

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, December 27, 2016 7:58 AM

All replies

  • Hi,

    Have you enable publishing feature for your site? Seems it’s not compatible currently, here are some threads for your reference.

    http://www.wictorwilen.se/sharepoint-2013---introduction-to-the-minimal-download-strategy-mds

    http://steve.thelineberrys.com/gotchas-using-custom-web-parts-and-the-minimal-download-strategy/

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, December 21, 2016 8:03 AM
  • No it's a team site collection, so no publishing features enabled--MDS works just fine if my feature is deactivated, and MDS does a failover only while my feature is activated.

    I've already seen those two threads plus loads more web pages on MDS, but every one just seems to say that all that is needed is decorating your class with the MdsCompliant attribute, which you can see I did.

    I've tried to add the PageRenderMode to my .ascx file with both Standard and MinimalDownload to no avail.

    <SharePoint:PageRenderMode runat="server" RenderModeType="Standard" />

    Unless you're saying I need to program something to return the -deltaboundary token? But I don't know how to that, and I can't find anything on the internets on how. Can you explain?

    Wednesday, December 21, 2016 2:24 PM
  • Hi,

    Could you try to check if any warning/error in ULS logs for MDS.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, December 22, 2016 9:13 AM
  • Nope, the term MDS is nowhere to be found in the SharePoint ULS logs nor in the IIS logs (If I remove the MdsCompliant attribute it starts showing up in the ULS logs though). The IIS logs (attached) show the failover happening but each HTTP response is set to 200 (no error). Maybe something in SharePoint's JavaScript code is causing the failover, but why and what do I need to add to the UserControl to make it happy?

    2016-12-22 17:11:12 127.0.0.1 GET /sites/TS1/SitePages/Home.aspx AjaxDelta=1&isStartPlt1=1482426672106 80  127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko http://sp2013d.contoso.test/sites/TS1/_layouts/15/start.aspx 200 0 0 109
    2016-12-22 17:11:12 127.0.0.1 GET /sites/TS1 AjaxDelta=1&isStartPlt1=1482426672106 80  127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko http://sp2013d.contoso.test/sites/TS1/_layouts/15/start.aspx 200 0 0 14
    2016-12-22 17:11:12 127.0.0.1 GET /sites/TS1/SitePages/Home.aspx - 80  127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko http://sp2013d.contoso.test/sites/TS1/_layouts/15/start.aspx 200 0 0 314
    2016-12-22 17:11:14 127.0.0.1 GET /sites/TS1/Shared+Documents/Forms/AllItems.aspx AjaxDelta=1&isStartPlt1=1482426674261 80  127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko http://sp2013d.contoso.test/sites/TS1/_layouts/15/start.aspx 200 0 0 82
    2016-12-22 17:11:14 127.0.0.1 GET /sites/TS1/Shared+Documents/Forms/AllItems.aspx - 80  127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko http://sp2013d.contoso.test/sites/TS1/_layouts/15/start.aspx 200 0 0 249
    2016-12-22 17:11:16 127.0.0.1 GET /_layouts/15/viewlsts.aspx AjaxDelta=1&isStartPlt1=1482426676366 80  127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko http://sp2013d.contoso.test/sites/TS1/_layouts/15/start.aspx 200 0 0 71
    2016-12-22 17:11:16 127.0.0.1 GET /_layouts/15/viewlsts.aspx - 80  127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko http://sp2013d.contoso.test/sites/TS1/_layouts/15/start.aspx 200 0 0 187

    Thursday, December 22, 2016 5:25 PM
  • Hi,

    I tested this in my local, custom AdditionalPageHead delegate control will break MDS, it should be by design action currently.

    Seems it’s out of MDS support as described picture below:

    But some others delegate controls works fine, for example: SuiteLinksDelegate/ PromotedActions

    I would suggest not custom AdditionalPageHead delegate control currently.

    Best Regards,

    Lee

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, December 27, 2016 7:58 AM
  • So you're saying that this behavior is by design, and then you reposted the exact same link I posted in my original question, which specifically says to mark controls as MDS compliant so they don't break MDS. So the MSDN web page is incorrect, and it only applies to Web Parts?
    Tuesday, December 27, 2016 3:24 PM
  • Hi,

    Updated my previous post based on more testing, hope this could help.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, December 29, 2016 5:51 AM
  • Very helpful, thanks!
    Thursday, December 29, 2016 12:23 PM