4

When I add SPSecurity.CatchAccessDeniedException = false; this disables the redirection to a login site.

Does Sharepoint keep that setting until I set it to "true" or just as long until the object is disposed?

Or in other words: I want to be able to change that setting globally. Can this be done?

3

It is kept inside the current HttpContext. If you decompile the code you will see it:

public static bool CatchAccessDeniedException
{
  get
  {
    HttpContext current = HttpContext.Current;
    if (current == null)
      return false;
    string str = (string) current.Items[(object) "CatchAccessDenied"];
    if (!string.IsNullOrEmpty(str))
      return str.Equals("TRUE", StringComparison.InvariantCulture);
    else
      return true;
  }
  set
  {
    HttpContext current = HttpContext.Current;
    if (current == null)
      return;
    current.Items[(object) "CatchAccessDenied"] = value ? (object) "TRUE" : (object) "FALSE";
  }
}

So the setting you make is valid during the HttpRequest lifecycle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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