Sunday, 30 December 2012 15:44

redirecting to custom error pages in asp.net application

Written by 
Rate this item
(0 votes)

in asp.net application there may be different
server errors like file not found,server error,
etc.when those errors happens default ASP.NET error
page is shown which looks odd and users don't
understand what type of errors occured.to overcome
these problems it's a good idea to use own
error files.

I always add the following settings
in my web.config file to show specific error
pages -

under <system.web> add -

<customErrors defaultRedirect="error.html" mode="On">
<error statusCode="500" redirect="server_error.html"/>
<error statusCode="403" redirect="error_noaccess.html"/>
<error statusCode="404" redirect="error_filenotfound.html"/>
</customErrors>

There are 3 error modes on which ASP.NET application works:
Off Mode,On Mode,RemoteOnly Mode

here i used On mode to show specific error page according
to statusCode.if you use Off mode then asp.net default
error pages shown.

Read 1146 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments