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!