title: ASP.NET WindowsAuthentication custom 401 Unauthorized error page
body: <p>I have an ASP.NET web-site with authentication using ActiveDirectory.  </p>
  
  <p><strong>Now</strong>, when an authenticated user opens a page - he is automatically authenticated. I have faced a problem - when a non-authenticated user (<em>for example, a Mozilla Firefox user with not defined <code>network.automatic-ntlm-auth.trusted-uris</code> property</em>) opens a page, IIS sends 401 response and prompts for a login \ password.</p>
  
  <p><strong>What I want is</strong> not to prompt him for a login \ password - just show a custom error page. It sounds pretty simple - authenticated users get the requested page, non-authenticated are redirected to a custom error page. It would work fine for FormsAuthentication. </p>
  
  <p>However, I have tried so many ways by now. Any Web.config redirects are not working. Even if I clear a <code>Response</code> and put there a redirect - I will get a loop because this custom page (*e.g., <code>/Error/AccessDenied</code>) also requires authentication. Marking a controller as <code>AllowAnonymous</code> does nothing.</p>
  
  <p>However, if I enable Anonymous authentication in IIS Manager, real authenticated domain users are not being authorized when they open a web-site.</p>
  
  <p>How can I solve this problem?</p>