Ads

Saturday, 16 March 2013

Use of AllowUnsafeUpdates property & its benefits

This is a property of SPSite & SPWeb objects of sharepoint

Sometime if user don't have sufficient permission to update data, in that case we run the code with system account privilege by using RunWithElevatedPrivileges block.

So by setting AllowUnsafeUpdates to true to disable security validation on Update() method.

This is recommended if persisting anything within RunWithElevatedPrivileges. 
Any exception, handled or otherwise, sets AllowUnsafeUpdates to False.

Ex:
SPSite site = new SPSite(Site URL);
SPWeb oWeb = oSite.OpenWeb();
oWeb.AllowUnsafeUpdates = True;
....

No comments:

Post a Comment

Ads