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

Calling BreakRoleInheritance(false)on a List, internally flips the AllowUnsafeUpdates flag to false, and this may lead to below mentioned error, if we do not explicitly set the AllowUnsafeUpdates to true again.

When any object that implements ISecurable (those are SPWeb, SPList and SPListItem) breaks or reverts their role definition inheritance. This means every time you call
SPRoleDefinitionCollection.BreakInheritance(), BreakRoleInheritance(), ResetRoleInheritance() or set the value of HasUniquePerm the AllowUnsafeUpdates
property of the parent web will reset to its default value and you may need to set it back to true in order to do further updates to the same objects.

Therefore, it can be safely concluded that , if we intend to do SPWeb and SPSite modifications after a call to BreakRoleInheritance for a List, a recommended usage
is to couple it with an explicit setting of AllowUnsafeUpdates property to true for the web & site again.

Attaching Sample code


SPSite objSPSite = new SPSite("<ServerURL>");
SPWeb objSPWeb = objSPSite.OpenWeb(objSPSite.OpenWeb().ID);
SPListCollection lists = objSPWeb.Lists;

Guid docLibGuid = lists.Add("Doc Lib 1", "Doc Lib Desc", SPListTemplateType.DocumentLibrary);

SPList docLib = lists[docLibGuid];
docLib.EnableVersioning = true;
docLib.OnQuickLaunch = true;

objSPWeb.AllowUnsafeUpdates = true;

docLib.BreakRoleInheritance(false); //Exception is thrown in this line of code.

When we remove docLib.BreakRoleInheritance(false) everything works fine.

Will have to change the last two lines of code as below

docLib.BreakRoleInheritance(false); //Exception is thrown in this line of code.
objSPWeb.AllowUnsafeUpdates = true;