The security validation for this page is invalid.


When you working with sharepoint and  you encounter with this error:

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again:

Solution is easy:

set “AllowUnsafeUpdates” propery true.

Example:

Guid webID = SPContext.Current.Web.ID;
Guid siteID = SPContext.Current.Site.ID;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
    using (SPSite site = new SPSite(siteID))
    {
        site.AllowUnsafeUpdates = true;
        using (SPWeb web = site.OpenWeb(webID))
        {
            web.AllowUnsafeUpdates = true;
            //your code here...
        }
    }
}

Unknown's avatarAbout bpostaci
Escalation Engineer in Microsoft.

Leave a comment