Implementing a Custom Error page on an ASP.Net website
Try this way, almost same.. but that's what I did, and working.
<configuration> <system.web> <customErrors mode="On" defaultRedirect="apperror.aspx"> <error statusCode="404" redirect="404.aspx" /> <error statusCode="500" redirect="500.aspx" /> </customErrors> </system.web></configuration>
or try to change the 404 error page from IIS settings, if required urgently.
There are 2 ways to configure custom error pages for ASP.NET sites:
- Internet Information Services (IIS) Manager (the GUI)
- web.config file
This article explains how to do each:
The reason your error.aspx page is not displaying might be because you have an error in your web.config. Try this instead:
<configuration> <system.web> <customErrors defaultRedirect="error.aspx" mode="RemoteOnly"> <error statusCode="404" redirect="error.aspx"/> </customErrors> </system.web></configuration>
You might need to make sure that Error Pages
in IIS Manager - Feature Delegation is set to Read/Write:
Also, this answer may help you configure the web.config file:
<customErrors defaultRedirect="~/404.aspx" mode="On"> <error statusCode="404" redirect="~/404.aspx"/></customErrors>
Code above is only for "Page Not Found Error-404" if file extension is known(.html,.aspx etc)
Beside it you also have set Customer Errors for extension not known or not correct as
.aspwx
or .vivaldo
. You have to add httperrors
settings in web.config
<httpErrors errorMode="Custom"> <error statusCode="404" prefixLanguageFilePath="" path="/404.aspx" responseMode="Redirect" /></httpErrors><modules runAllManagedModulesForAllRequests="true"/>
it must be inside the <system.webServer>
</system.webServer>