The security validation for this page is incorrect. Click Back in your Web browser, refresh the page and retry the operation
- A custom webpart which on filling the info path form; creates a folder and a file inside the folder, in the SharePoint Document Library.
- When we fill the Info Path form and submit the request ; the folder and the file is created inside the SharePoint Document Library
- We then try to have the custom permissions for each item through BreakRoleInheritance .
- We end up in getting ERROR: “The security validation for this page has timed out. Click Back in your Web browser, refresh the page, and try your operation again”
Root Cause: Trying to update the permissions through BreakRoleInheritance from a webpart under SPSecurity.RunwithElevatedPrivileges
Resolution / WorkAround:
- SOLUTION 1:
Create SPSite Object
Add Lines: SPUtility.ValidateFormDigest(); (Note: SPUtility is found in Microsoft.Sharepoint.Utilities class)
Create SPWeb Object
Add the SPWeb.AllowUnsafeUpdates = true ;
/* The code which contains the permissions managing through BreakRoleInheritance */
Add the SPWeb.AllowUnsafeUpdates = false;
- SOLUTION 2:
- Re- Add the line : SPWeb.AllowUnsafeUpdates = true AFTER Item.BreakRoleInheritance(true) is added.
- REASON: The call to method BreakRoleInheritance makes the SPWeb.AllowUnsafeUpdates= false internally. So now, if we do any updates; it causes the error. So we need to re-add the lines to make the AllowUnsafeUpdates to true for SPWeb object