title: customerrors for 401.2 in ASP.NET
body: <p>I successfully implemented role based authorization in ASP.NET. When a person does not have the needed role he gets to see an error page for 401.2 not authorized. </p>
  
  <p>What I would like to accomplish now is to have a custom 401 page in my application and have it redirected there via settings in the web.config. I tried this:</p>
  
  <pre><code>&lt;customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"&gt;
      &lt;error statusCode="401" redirect="NoAccess.htm" /&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>But this does not get caught. Do I have to override it in IIS instead? I hope not as that would make getting things deployed harder.</p>