Tuesday 21 May 2013

Editing items programatically from sitecore : security exception


When using Sitecore.Context to update items you may run into a security exception saying that the ASP.Net process doesn't have permission to update the database.

You can get around that very easily by using a security override by wrapping your code in this block:

 using (new Sitecore.SecurityModel.SecurityDisabler())
{
  //retrieve item

  item.Editing.BeginEdit();

  //update item

 item.Editing.EndEdit();
}

This is likely to happen if you are using the Sitecore master database directly so as to bypass publishing



No comments:

Post a Comment