ASP.Net partially ignoring my Custom error section in web.config
Here's my web.config customErrors section (you'll notice I've switched the mode to 'On' so I can see the redirect on my localhost):
<customErrors defaultRedirect="~/Application/ServerError.aspx" mode="On" redirectMode="ResponseRewrite">
<error statusCode="403" redirect="~/Secure/AccessDenied.aspx" />
</customErrors>
and here's the code that throws:
Catch adEx As AccessDeniedException
Throw New HttpException(DirectCast(HttpStatusCode.Forbidden, Integer), adE开发者_C百科x.Message)
End Try
and here's what I end up with:
Which is not my pretty AccessDenied.aspx page but it is a forbidden error page so at least I know my throw is working.
I've removed the entry for 403 in IIS (7.0) as a desperate last attempt and unsuprisingly that made no difference.
I've run out of ideas now so any suggestions will be gratefully appreciated!
In fact, your aspx page may not be executing at all.
Go to IIS.
Go to your default website properties.
Click on the Home Directory Tab
Click the configuration button.
Now, check if a .aspx page is registered there.
You need to specify existingResponse="PassThrough"
in the system.webServer section of the httpErrors element.
<configuration>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
精彩评论