I am using following setting for customErrors in my web.config.
<customErrors mode="On" defaultRedirect="GenericErrorPage.aspx" >
<error statusCode="403" redirect="NoAccess.aspx" />
<error statusCode="404" redirect="FileNotFound.aspx" />
</customErrors>
I have a folder "Admin" having access to administrators role. When someone other than administrators tries to access the pages inside admin folder, it is redirected to login page. My expectation is to display "NoAccess.aspx".
Whats wrong with this code? Or is there another meaning to statusCode 403.
If you’re using IIS 7 then the error pages should be set here:UPD:
Ok, after reviewing the question I realised that the problem is in something else..
By default the authentication system in ASP.NET redirects all 403 requests to the login page. This is the way it’s coded, and yes, it ignores the we.config settings.
There are solutions, of course.. You can check an example of how it was solved here ( similar question of SO )
With ASP.NET membership, how can I show a 403?
Good luck!