Anyone run into this? Here's the exact error:
Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.
What I'm trying to do is to add an Announcement programatically. While I guess I could do the AllowUnsafeUpdates, I'm wondering if there is a way to do it without doing that. I'd like to do it the safest way possible. I'm utilizing the SmartPart and using my own UserControl. Anyway I can make this be a "POST"? I might just be really dumbed down right now as it's Friday, so please take it easy on me if it's really simple! haha Any hoo, here's my code:
foreach (SPList list in SPWeb.Lists)
{
Response.Write (list.Title + list.GetType().ToString() + "<br>");
if (list.Title == "Announcements")
{
SPListItemCollection listItems = list.Items;
SPListItem newitem = listItems.Add();
newitem["Title"] = "Test" + list.Items.Count.ToString();
newitem["Body"] = "testbody for item #" + list.Items.Count.ToString();
newitem["Expires"] = System.DateTime.Now.AddDays(1);
newitem.Update();
list.Update();
}
}