title: Login Dialog Appears When User is Not Authorized
body: <p>In an attempt to implement security in my web app, I created an attribute that derives from <code>AuthorizeAttribute</code>.</p>
  
  <pre><code>public class FunctionalityAttribute : AuthorizeAttribute
  {
      public string FunctionalityName { get; set; }
  
      protected override bool IsAuthorized(HttpActionContext actionContext)
      {
          string adGroup = WebConfigurationManager.AppSettings[FunctionalityName];
  
          if (actionContext.RequestContext.Principal.IsInRole(adGroup)) { return true; }
  
          return false; // This causes a login dialog to appear. I don't want that.
      }
  }
  </code></pre>
  
  <p>And here is how it's used in my Web API method:</p>
  
  <pre><code>[Functionality(FunctionalityName = "GetApps")]
  public IEnumerable&lt;ApplicationDtoSlim&gt; Get()
  {
      using (var prestoWcf = new PrestoWcf&lt;IApplicationService&gt;())
      {
          return prestoWcf.Service.GetAllApplicationsSlim().OrderBy(x =&gt; x.Name);
      }
  }
  </code></pre>
  
  <p>It actually works. But the issue is what happens when I'm not authorized:</p>
  
  <p><a href="https://i.stack.imgur.com/dH4kp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dH4kp.png" alt="enter image description here"></a></p>
  
  <p>I don't want that dialog to come up. I'm already signed in. I want to let the user know that they're not authorized. How do I make it so that login dialog doesn't come up?</p>