4

Is SPWeb AllowUnsafeUpdates is an expensive process ?

I want to do it 3-4 times, is it heavy process ?

2 Answers 2

7

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.

1
  • well explained.
    – kesava
    Commented Aug 12, 2015 at 0:16
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.