ASP.Net Swallowing 404 Error
So I've set up a rule in IIS7 to redirect to a specific page on a 404 error.
This works great as long as I'm typing URLs such as:
www.abc.com/Test/
However as soon as I attempt to access a file that doesn't exist
www.abc.com/Test/Test.aspx
I get the ASP.Net error message:
Server Error in '/' Application.
The resource cannot be found.
H开发者_如何学Cow can I keep ASP.Net from swallowing the 404 error and overriding my settings in IIS7?
EDIT: Here's my web.config file. IIS added the system.webServer stuff not me.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<httpErrors>
<remove statusCode="403" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/redir.aspx" responseMode="ExecuteURL" />
<error statusCode="403" prefixLanguageFilePath="" path="/redir.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
If you're in Classic pipeline mode, you may be able to use the "Invoke handler only if request is mapped to file" option. I had to turn it on for two .aspx mappings--I think one was 32 bit and one was 64.
精彩评论