The security validation for this page is invalid
-
10-12-2020 - |
Question
Server Error when updating a field:
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
var creatdbyfield = spList.Fields["Created By"];
creatdbyfield.ReadOnlyField = false;
creatdbyfield.Update();
Crashing on the Update() call. Has anyone seen this before?
Solution
Use below code :
web.AllowUnsafeUpdates = true; //here web is the spweb object
var creatdbyfield = spList.Fields["Created By"];
creatdbyfield.ReadOnlyField = false;
creatdbyfield.Update();
web.AllowUnsafeUpdates = false;
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange