Recently I have been doing some work with Content Types via the SharePoint object model and as well as the read only issue which I have also posted about I ran into a security issue. Whenever attempting to update a content type and propagate all children I would receive the following error:
“The security validation for this page is invalid”
This one took quite a while for me to get to the bottom of and as it turned out all that was required to fix it was disabling security validation by setting the .FormDigestSettings property before the content type update statement as discussed here.
Having read the above I proceeded to
using (SPSite site = new SPSite(strSite))
site.AllowUnsafeUpdates = true;
using (SPWeb web = site.OpenWeb())
// update will fail unless security validation is disabled
SPWebApplication webApp = web.Site.WebApplication;
webApp.FormDigestSettings.Enabled = false;
web.AllowUnsafeUpdates = true; // code goes here
// update including children
// re-enable security validation
webApp.FormDigestSettings.Enabled = true;
site.AllowUnsafeUpdates = false;
}); By disabling the .FormDigestSettings prior to the update combined with allowing unsafe updates I was able to propagate content type changes to children without receiving any errors. Hooray!