Sharepoint SPWeb rename - Exception SPException - The security validation for this page is invalid
When attempting an SPWeb rename I receive the following SPException:
Exception SPException - The security validation for this page is invalid. Click Back in your开发者_运维百科 Web browser, refresh the page, and try your operation again. - Failed to create workgroup registration entry
Any idea what might be the troubles here? Here is the relevant code:
SPSecurity.RunWithElevatedPrivileges(() =>
{
using (SPWeb thisWeb = site.OpenWeb(webUrl))
{
thisWeb.Title = newName;
thisWeb.Update();
}
});
1) Set SPWeb.AllowUnsafeUpdates = true
2) You may need to validate the FormDigest with ValidateFormDigest
SPSecurity.RunWithElevatedPrivileges(() =>
{
using (SPWeb thisWeb = site.OpenWeb(webUrl))
{
try
{
thisWeb.AllowUnsafeUpdates = true;
if (!thisWeb.ValidateFormDigest())
throw new InvalidOperationException("Form Digest not valid");
thisWeb.Title = newName;
thisWeb.Update();
}
finally
{
if(thisWeb != null)
thisWeb.AllowUnsafeUpdates = false;
}
}
});
精彩评论