Thursday, November 20, 2008

The security validation for this page is invalid

Scenario:
You have create a new ASPX page and trying to run it under SharePoint context. If the page Postback you get the following error.
The security validation for this page is invalid.

Reason:
SharePoint uses Form validation digest to stop attacks.

Solution:
1. You can disable the security
http://www.sharepointblogs.com/nicksevens/archive/2007/11/23/edit-sharepoint-security-in-c-quot-the-security-validation-for-this-page-is-invalid-quot.aspx

2. Use the SharePoint master page to get the correct 'form' for your page. What I mean by that is , there is a sharepoint control which takes care of security validation. All the sharepoint master pages have it. So if you use sharepoint master page this is taken care.( BEST )

3. Add the form details into the page manually.
http://epham.wordpress.com/2007/01/22/how-to-fix-security-validation-errors-in-sharepoint-aspnet-page/

4. Allow unsafe update ( if updating sharepoint objects )
http://blogs.msdn.com/sridhara/archive/2008/06/21/the-security-validation-for-this-page-is-invalid-error-when-updating-objects-through-sharepoint-object-model.aspx

2 comments:

Unknown June 26, 2009 at 2:33 AM  

Hey,

What do you mean by "Use the SharePoint master page to get the correct 'form' for your page".

How do i identify the right form?

Sandeep June 26, 2009 at 8:18 AM  

checkout, I added more description to it.