ASP.NET: disabling authentication for a single aspx page (page with user errors)?

I am using a custom error page in IIS 6:

<customErrors redirectMode="ResponseRedirect" mode="On" defaultRedirect="Error2.aspx"/>

I want to disable authentication for the user error page because the error occurred is related to the authentication module, and I do not want to end up in an infinite loop, and I want to show the user a clean error page. I tried the following configuration to do this.

<location path="Error2.aspx">
 <system.web>
   <authentication mode="None"/>
   <authorization>
     <allow users="?"/>
     <allow users="*"/>
   </authorization>
 </system.web>
</location>

I get a System.Configuration.ConfigurationErrorsException for a string that sets authentication mode.

An error occurred while using a section registered as allowDefinition = 'MachineToApplication' that is higher than the application level. This error can be caused by the fact that the virtual directory is not configured as an application in IIS.

, web.config. IIS, . , IIS, Windows ( ).

+5
3

, Response. , , , ..

, (, MVC-?), .

, , - , .

+1

. , location.

<location path="404.aspx">
    <system.web>
       <authorization>
          <allow users="*" />
       </authorization>
    </system.web>
</location>

, , web.config , .

+1

IIS , IIS (machine.config) ( system.web.authentication, system.web.authorization, , ).

After that, clear your decision and rebuild. I had this problem and it had nothing to do with the settings of machine.config or web.config. For some reason, the cleanup and recovery made the error go away.

0
source

All Articles