I am getting good old "The security validation for this page is invalid" on Sharepoint 2013, while updating list in Sharepoint, due to button click on an application page.
In browser, I clearly see, that this is a POST request. While debugging, I clearly see Context.Request.HttpMethod == "POST"
.
I've tried adding FormDigest
tag and calling ValidateFormDigest
-- did not help.
What helped was the following:
using (SPWeb web = CurrentSite.OpenWeb())
{
web.AllowUnsafeUpdates = true;
// List update here
web.AllowUnsafeUpdates = false;
}
On MSDN, it is stated, that AllowUnsafeUpdates
works only for GET requests.
How is that happening, that it is required even for my POST request? Am I doing everything correct?