.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

The security validation for this page is invalid error in sharepoint

Posted By:Sunil Yadav       Posted Date: June 30, 2010    Points: 25    Category: SharePoint    URL: http://www.dotnetspark.com  

This article explains how to get rid of "The security validation for this page is invalid" error in sharepoint.


While working on sharepoint object model you may get an error "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."

 Following are the ways in which we can get rid of this error.

    1.Go to Central Administration->application management-->web application settings->"Web Page Security Validation" and Turn off security validation.

but the above is not valid as it can lead to security voilation and can be dangerous.

2.Setting AllowUnsafeUpdates to True can resolve problem related to Object Model. Setting this property to true opens security risks, potentially open to malicious code.



    //Your code goes here


3.Disable the FormDigestSettings for the time of your code execution and should be revert back.


SPSite site = SPContext.Current.Site;
site.WebApplication.FormDigestSettings.Enabled = false; //Your code goes here.. site.WebApplication.FormDigestSettings.Enabled = true; //Or you can use following SPWeb web = site.OpenWeb(); SPWebApplication webApp = web.Site.WebApplication; webApp.FormDigestSettings.Enabled = false; //Your code goes here.. webApp.FormDigestSettings.Enabled = true;

4.Call SPUtility.ValidateFormDigest().


SPUtility.ValidateFormDigest(); web.AllowUnsafeUpdates = true; //Your code goes here..

web.AllowUnsafeUpdates = false;

Hope this helps.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend