Recently I talked about a WithWeb-pattern as described in Jonas Nilssons blog where you can isolate the disposal logic in one place. Another thing is to isolate unsafe updates:
public static class SPWebExtension { public static void UnsafeUpdate(this SPWeb web, Action<SPWeb> action) { try { Log.Info("Trying to do an unsafe update on a web: " + web.Title); web.AllowUnsafeUpdates = true; action(web); } catch (Exception e) { Log.Error(e); } finally { web.AllowUnsafeUpdates = false; } } }
The Log class is my own class which I presented in my previous post.
