SharePoint In Action

An attempt to share my day-to-day SharePoint experience

Archive for the tag “SharePoint 2010 List Batch Update”

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

Hi all,

I just got this error while developing a web part to batch update a SharePoint list. The solution was adding one line of code that allows running the update command on a list without requiring a security validation. This should be place right before your update command.

Consider the code snippet below:

SPSite siteCol = new SPSite(YourSiteURL);
SPWeb web = siteCol.OpenWeb();
SPList list = web.Lists[YourListName];
web.AllowUnsafeUpdates = true;

{your list update code goes here}

Setting this property to true opens security risks, potentially introducing cross-site scripting vulnerabilities.

p.s. You can also use web.Site.WebApplication.FormDigestSettings.Enabled = false before your update and set it to true after

Nader Heshmat

Post Navigation