How To: MOSS: Work with RunWithElevatedPrivileges
BEHAVIOR/SYMPTOMS:
====================
if the code is not set inside RnWithElevatedPrivileges then you may get following errors
Error:
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
Troubleshoot issues with Windows SharePoint Services.
ESOLUTION/WORKAROUND:
====================
please refer the article mentioned below and follow the following code snippet
Code:
====================
string siteURL = SPContext.Current.Site.Url;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite objSite = new SPSite(siteURL);
SPWeb objWeb = objSite.OpenWeb();
SPList list = objWeb.Lists["customer"];
SPListItem item = list.GetItemById(1);
objWeb.AllowUnsafeUpdates = true;
item["test"] = System.DateTime.Now.ToString();
item["AlertSent"] = true;
item.Update();
objWeb.AllowUnsafeUpdates = false;
objSite.Close();
objWeb.Close();
});
Note: Please modify the above code with the "List & Field name"(highlighted).