Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hbulens/bf42dd5ea68e4259efbcdaa2b37fe111 to your computer and use it in GitHub Desktop.
Save hbulens/bf42dd5ea68e4259efbcdaa2b37fe111 to your computer and use it in GitHub Desktop.
public static class SPWebExtensions
{
public static void RunWithUnsafeUpdates(this SPWeb currentWeb, Action action)
{
bool allowUnsafeUpdates = currentWeb.AllowUnsafeUpdates;
currentWeb.AllowUnsafeUpdates = true;
try
{
action.Invoke();
}
finally
{
currentWeb.AllowUnsafeUpdates = allowUnsafeUpdates;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment