Question

I have to deactivate the MDS when provisioning my sites. I have tried with an event receiver in a custom feature but it seems that when I execute this code in the receiver

Guid featureGuid = new Guid("87294C72-F260-42f3-A41B-981A2FFCE37A");
if (mySiteWeb.Features[featureGuid] != null)
{
     mySiteWeb.Features.Remove(featureGuid);
}

nothing is happenning.

This only works once the my site is created and throughout the User Interface. If I go to Manage Site Features and Deactivate and Activate my custom feature manually the MDS turns off.

Any idea how to achieve this?

Was it helpful?

Solution

We had the same problem. We had a stapling feature that was applying branding to my personal sites. Staplers code ran, but MDS was still active. What we did, was to add a custom control to a personal site master page which deactivated MDS when site was loaded. In this custom control we added if/else check if this code ran once ( by putting value to web.properties) and if it did already, just did not deactivate it again.

We were able to do this, as this was a farm solution. If you are on Office 365 etc, you need to do "Application Stapling"

http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2013/03/04/sharepoint-2013-app-deployment-through-quot-app-stapling-quot.aspx

OTHER TIPS

PowerShell below will update the current farm “MDSFeature” XML to disable for all newly created site collections and child webs. If you need to support IE8 and older browsers this can be helpful. The feature GUID technically remains active but won’t do anything with missing DLL assembly detail. After desktops upgrade (IE11/Win8) then this change can be reversed with a simple file copy “ORIG” back to “XML.” Hope this helps!

http://www.spjeff.com/2015/02/13/knee-cap-mds-disable-for-new-and-current-sites/

# Disable MDS - run once per farm
# unregister Feature definition from ConfigDB
Uninstall-SPFeature MDSFeature -Force -Confirm:$false

# backup current Feature XML
$path = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES\MDSFeature\feature.xml"
Copy-Item $path "$path-orig"

# modify Feature XML to suppress DLL assembly detail  (still registered, but unable to run)
[xml] $x = Get-Content $path
$x.Feature.RemoveAttribute("ReceiverClass")
$x.Feature.RemoveAttribute("ReceiverAssembly")
$x.Save($path)

# register Feature to ConfigDB
Install-SPFeature MDSFeature

I'm not finished testing this, but if you're changing the master page, you can add the following to disable MDS(it will render the page in standard mode nomatter if MDS is activated or not):

<SharePoint:PageRenderMode runat="server" RenderModeType="Standard" />
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top