Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

1 Answer

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
{
  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.

share|improve this answer
add comment

Your Answer

 
discard

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.