Freigeben über


The security validation for this page is incorrect. Click Back in your Web browser, refresh the page and retry the operation

Issue Description:

  1. A custom webpart which on filling the info path form; creates a folder and a file inside the folder, in the SharePoint Document Library.
  2. When we fill the Info Path form and submit the request ; the folder and the file is created inside the SharePoint Document Library
  3. We then try to have the custom permissions for each item through BreakRoleInheritance .
  4. 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:
    1. Create SPSite Object

    2. Add Lines: SPUtility.ValidateFormDigest(); (Note: SPUtility is found in Microsoft.Sharepoint.Utilities class)

    3. Create SPWeb Object

    4. Add the SPWeb.AllowUnsafeUpdates = true ;

                           /* The code which contains the permissions managing through BreakRoleInheritance */

      Add the SPWeb.AllowUnsafeUpdates = false;

  • SOLUTION 2:
    1. Re- Add the line : SPWeb.AllowUnsafeUpdates = true AFTER Item.BreakRoleInheritance(true) is added.
    2. 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