When I try to deploy the project via PowerShell, PS proceed the "Enable-SPFeature" operation, then it prints the error message below:
Enable-SPFeature : The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. At E:\Demo\DemoProject\DemoProject\scripts\utility.ps1:315 char:19 + Enable-SPFeature <<<< -identity $id -url $url -confirm:$false + CategoryInfo : InvalidData: (Microsoft.Share...etEnableFeature:SPCmdletEnableFeature) [Enable-SPFeature], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletEnableFeature
Can anyone provide a solution?
Whenever we update any list item, list or SPWeb
instance you may get "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again". This is because of some security validation while updating the modification to the content database, so, in order to escape from that exception we have to make AllowUnsafeUpdates
property of the SPWeb
instance as true.
SPWeb oWeb = new SPWeb();
oWeb.AllowUnsafeUpdates = true;
AllowUnsafeUpdates
property is used to Gets or sets a Boolean value that specifies whether to allow updates to the database as a result of a GET request or without requiring a security validation. SPSite
class also has this property.