In this post we will discuss about the solution to SharePoint error "The security validation for this page is invalid error SharePoint 2010". And also how to use FormDigest control in SharePoint 2010
For reasons of security, by default, Microsoft SharePoint Foundation does not allow you to make posts from a Web application to modify the contents of the database unless you include security validation on the page making the request.
But you can update data for a single site or for a site collection by adding a page directive and a FormDigest control to the page that makes the request.
For this we need to do 2 things:
Register the SharePoint web controls assembly in your aspx like below at top of the .aspx page:
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Place the FormDigest control on the .aspx page like below:
<sharepoint:formdigest id="FormDigest1" runat="server" />
Through code also we can do this like below:
protected override void OnInit(EventArgs e)
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.
Hope now the error will not come.