SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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

public static bool CatchAccessDeniedException
    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);
      return true;
    HttpContext current = HttpContext.Current;
    if (current == null)
    current.Items[(object) "CatchAccessDenied"] = value ? (object) "TRUE" : (object) "FALSE";

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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