Reputation: 131
I am using FriendlyUrl which gets rid off all .aspx extensions. However, when I set customError in my web.config file it only works if the error is caused on a path with .aspx extension.
Ex that does not go to my own error-page:
localhost:xxxxx/DefaultMissSpelled
Ex that goes to my own error-page:
localhost:xxxxx/DefaultMissSpelled.aspx
I actually have to manually add the .aspx
to get it to work, or I just get the default asp.net error-page.
Web.config:
<customErrors defaultRedirect="Errors/DefaultError.aspx" mode="On">
<error statusCode="404" redirect="Errors/Filenotfound.aspx" />
</customErrors>
(I have tried with and without .aspx extension inside web.config).
Upvotes: 3
Views: 1252
Reputation: 2592
Try this one:
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" responseMode="Redirect" path="/page-not-found"/>
</httpErrors>
</system.webServer>
change the path name with your friendly url
and this is for IIS 6
<system.web>
<customErrors mode="RemoteOnly">
<error statusCode="500" redirect="~/internal-server-error"/>
<error statusCode="404" redirect="~/page-not-found"/>
</customErrors>
</system.web>
Upvotes: 2