title: ASP.NET: disabling authentication for a single aspx page (custom error page)?
body: <p>I am using a custom error page in IIS 6:</p>
  
  <pre><code>&lt;customErrors redirectMode="ResponseRedirect" mode="On" defaultRedirect="Error2.aspx"/&gt;
  </code></pre>
  
  <p>I want to disable authentication for the custom error page because the error being raised is related to an authentication module and I don't want to get into an infinite loop and I want to display a clean error page to the user.  I have been trying the following configuration to do that.</p>
  
  <pre><code>&lt;location path="Error2.aspx"&gt;
   &lt;system.web&gt;
     &lt;authentication mode="None"/&gt;
     &lt;authorization&gt;
       &lt;allow users="?"/&gt;
       &lt;allow users="*"/&gt;
     &lt;/authorization&gt;
   &lt;/system.web&gt;
  &lt;/location&gt;
  </code></pre>
  
  <p>I am getting a System.Configuration.ConfigurationErrorsException for the line that sets the authentication mode.</p>
  
  <blockquote>
    <p>It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.</p>
  </blockquote>
  
  <p>I have verified that there are no other web.config files in subdirectories under the application's folder.  The applications folder is configured as an application in IIS and the error page is at the application's root.   File permissions set for the error page in IIS include anonymous and windows authentication (I have tried just anonymous as well).</p>