Sunday, September 21, 2014

Security-validation-for-this-page-is-invalid-error-sharepoint

Hi All,

Sometimes we receive below error when we are doing any update is list or library using the SharePoint object model.

 


This is because SharePoint does not allows you make any changes in Content Database. To make any post from a Web application that modify the contents of the database, you must include the FormDigest control in the form making the post. The FormDigest control generates a security validation, or message digest, to help prevent the type of attack whereby a user is tricked into posting data to the server without knowing it. The security validation is specific to a user, site, and time period and expires after a configurable amount of time. When the user requests a page, the server returns the page with security validation inserted. When the user then submits the form, the server verifies that the security validation has not changed.”








and you need to validate it in your server side code...











Other solution is use web.AllowUnsafeUpdates=true in your code.

SPWeb _web=SPContext.Current.Web;
_web.AllowUnsafeUpdates=true;

Put you code here to make changes in list or library.

//Set back it state
_web.AllowUnsafeUpdates=false;

Reference:

http://msdn.microsoft.com/en-us/library/office/cc768615(v=office.14).aspx


No comments:

Post a Comment

SharePoint Deployment Error : The specified path, file name, or both are too long.

Hi, Sometimes we get surprised with below error while deploying wsp file... Solution : To overcome with this issue, we just ne...