Friday, September 11, 2009

Security Validation error in sharepoint


While creating one of the sites from the browser i came an error saying "The security validation for this page is invalid. Click Back in your Webbrowser, refresh the page, and try your operation again"
I got bit confused as i didn't know where to find and sort it out so i checked few sections in central admin site found one place. You can check for this :
  • Navigate thru the following Central Administration Site->application management->web application settings->"turn security validation off"
If above is ok then you may also check out below alternate
  • The Windows SharePoint Services Web site is configured to use Anonymous Access in addition to another method of authentication, such as Basic Authentication. Turn off the Basic Authentication from ISS->your sharepoint site-> right click properties->Directory Security tab
  • The last alternate is if you need code fix




sing (SPSite site = new SPSite(parentSiteUrl))
{
        site.AllowUnsafeUpdates = true;
        using (SPWeb web = site.OpenWeb())
        {
            web.AllowUnsafeUpdates = true;
            SPList list = web.Lists["mylist"];
            _listItem = clientsList.Items.Add();
            _listItem["Title"] = "test";
            _listItem.Update();                    }
        }
}
One of the above alternate should help you out