The Security Validation is invalid – SharePoint Application Page

The Security Validation is invalid – SharePoint Application Page

I was working on a SharePoint Application Page to allow limited users to cancel a workflow on a certain item in a Document Library and leave some Comments.

When testing my solution, I recieved the following error: “The security validation for this page is invalid. Click Back in your Web browser…”

This is due to the security applied to the SharePoint site, it disables the request as it deems it as harmful. In order to correctly execute the code, you will need to allow unsafe updates to the SharePoint site while the code is performed.

Before the code you wish to perform add the following:

web.AllowUnsafeUpdates = true

This will allow your code to execute, however in order to protect the security on the SharePoint site make sure you set this to false at the end of your code:

web.AllowUnsafeUpdates = false

Hope this helps some of you, it was bugging me for ages! :-)

One thought on “The Security Validation is invalid – SharePoint Application Page

  1. sacbar

    I have written a web service and used the SPSecurity.RunWithElevatedPrivileges to access a list to do some operations. But when I access that web service through the application, it asks for user name and password. Ideally it should not ask for user name and password. Please tell me – what should I have to do so that user name and password will not be asked for accessing the web service?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">