Reputation: 423
i am getting this error when trying to update an alert for a user in the team discussion list. My code is :
SPUser user = mysite.OpenWeb().CurrentUser;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite site = new SPSite(mysite.ID);
SPWeb myweb = site.OpenWeb();
string id = this.Page.Request.QueryString["RootFolder"].ToString();
string[] rootfolder = id.Split(@"//".ToCharArray());
myweb.AllowUnsafeUpdates = true;
SPList mylsit = myweb.Lists["Team Discussion"];
SPListItem item = mylsit.GetItemById(21);
SPUser curruser = myweb.EnsureUser(user.LoginName);
Response.Write(curruser.LoginName);
SPAlert newAlert = user.Alerts.Add();
newAlert.AlertType = SPAlertType.Item;
newAlert.Item = item;
newAlert.Properties["eventtypeindex"] = "1";
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
newAlert.Update(false);
myweb.AllowUnsafeUpdates = false;
});
And i am getting the error when the alert.update() is executing. please help me on this
Upvotes: 0
Views: 997
Reputation: 1327
The only thing I can see of note is the "! Important" section in the below MSDN article on the RunWithElevatedPrivileges function:
It would seem you are doing some form of writing, and may not have called ValidateFormDigest?
Upvotes: 1