asp.nethttp-redirectiis-7custom-errorsredirectmode

redirectMode="ResponseRewrite" doesn't work


I have 404.aspx to manage requests to non-existent pages. It works perfect on IIS6 but now I have to move it to IIS7. The website use .net 2.0 classic 32bit AppPool, no MVC.

non-.net requests like test.com/NotExist are managed well but I have issue with urls like test.com/NotExist.aspx I have configured .net err pages as follows:

<customErrors defaultRedirect="/404.aspx" mode="On">
   <error redirect="/404.aspx" statusCode="404" />
</customErrors>

and it works but converts url to test.com/404.aspx?aspxerrorpath=/NotExist.aspx

I must avoid this url change so I googled out I have to change a line:

<customErrors defaultRedirect="/404.aspx" mode="On" redirectMode="ResponseRewrite">

But it shows default error message instead of the result:

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

I checked https://stackoverflow.com/questions/12463412/responserewrite-redirect-mode-is-not-working and CustomErrors does not work when setting redirectMode="ResponseRewrite" and customErrors with redirectMode="ResponseRewrite" do not work on shared hosting but no luck.

Please help.


Solution

  • Handler Mappings -> *.aspx (I have four there, one named "PageHandlerFactory-ISAPI-2.0") -> edit -> Request Restrictions.

    We had checkbox "Invoke handler only if....." switched off. Now it is turned on and "File" radiobutton selected.