Exception : "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."


Sometimes whenever we update any list item, list or SPWeb instance you may get  "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again". This is because of some security validation while updating the modification to the content database, so, in order to escape from that exception we have to make AllowUnsafeUpdates property of the SPWeb instance as true.


SPWeb oWeb = new SPWeb();


oWeb.AllowUnsafeUpdates = true;


AllowUnsafeUpdates property is used to Gets or sets a Boolean value that specifies whether to allow updates to the database as a result of a GET request or without requiring a security validation. SPSite class also has this property.


 


Comments (1)
  1. Lars Nielsen says:

    Thanks for this – that error was driving me mad!

Comments are closed.

Skip to main content