Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a Custom Error page on an ASP.Net website

I have an ASP.Net website and I want to use a custom error page. I put the following code in my web.config

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

The problem is when i go to a URL that does not exist is still uses the 404 error page specified in IIS Manager.

Question: How can I make it use the error.aspx page I have created? Why do the settings in IIS Manager override the web.config?

like image 723
Yeodave Avatar asked Jan 29 '10 10:01

Yeodave


People also ask

How does ASP.NET handle custom errors?

In ASP.Net, error can be handled programmatically by writing appropriate code in the page-level error event, for errors on an individual page or in the application-level error event for handling errors that may occur in any page of the application.


1 Answers

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.

like image 141
Hrushikesh Avatar answered Sep 26 '22 10:09

Hrushikesh