So, I configured the rule in IIS7 to redirect to a specific page with a 404 error.
This works fine while I type in the urls, for example:
www.abc.com/Test/
However, as soon as I try to access a file that does not exist
www.abc.com/Test/Test.aspx
I get an ASP.Net error message:
Server error in application "/".
Resource is not found.
How can I keep ASP.Net from swallowing 404 errors and overriding my settings in IIS7?
EDIT: Here is my web.config file. IIS added the system.webServer file to 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>
source
share