Is SPWeb AllowUnsafeUpdates is an expensive process ?
I want to do it 3-4 times, is it heavy process ?
It might look like a property, but actually the setter of that property calls a method named SetAllowUnsafeUpdates(value)
which has the following code:
private void SetAllowUnsafeUpdates(bool allowUnsafeUpdates)
{
this.Request.SetIgnoreCanary(allowUnsafeUpdates);
}
SetIgnoreCanary
sets to ignore Canary (Canary is something that refers to a method of buffer overflow protection (https://en.wikipedia.org/wiki/Buffer_overflow_protection#Canaries)) and checks if permissions are properly propagated:
public void SetIgnoreCanary(bool bIgnoreCanary)
{
try
{
++this.m_UnmanagedStackCount;
this.EnsureRightsPropagated();
this.m_SPRequest.SetIgnoreCanary(bIgnoreCanary);
}
[....] SOME CODE OMITTED
}
by calling EnsureRightsPropagated
:
private void EnsureRightsPropagated()
{
if (this.m_pa.Permissions == this.m_permsAdded)
return;
this.m_SPRequest.GrantAdditionalPermissions((ulong) this.m_pa.Permissions);
this.m_permsAdded = this.m_pa.Permissions;
}
And the latter "assigns" additional permissions for the current SPRequest by calling GrantAdditionalPermissions
:
public void GrantAdditionalPermissions(ulong mask)
{
}
Which apparently is an empty method :)
So, I assume it's not very resource expensive.
it is no process at all, it is just a flag. But you should avoid it due to security reasons. If you place the Digest-Control from SharePoint on your page or do a SPUtility.ValidateDigest() by yourself in code, you should be able to update without AllowUnsafeUpdates