- Page Not Found - 404
- Internal server Error - 500
- Access Denied - 403
The above error page must have in one website. This is because when application catch error, the end users will see asp.net designed page without details error information that might not user friendly for the end users. To handle this errors, all you need to do are two things which is Create the above error page and set in Web.Config file in asp.net.
<configuration>
<system.web>
<customErrors defaultRedirect="~/500.html?" mode="RemoteOnly">
<error statusCode="404" redirect="~/404.html" />
<error statusCode="500" redirect="~/500.html" />
<error statusCode="403" redirect="~/AccessDenied.html" />
</customErrors>
</system.web>
</configuration>
As you can notice, i set the default error to defaultRedirect="~/500.html?" . The symbol "?" is to avoid web application passed unwanted querystring when the web application catch the error..
Modes Available List
Error Mode | Description |
RemoteOnly | Error page are shown for all end user except localhost user. Example if your website is accessible by domain abc.com, so everyone who access the website using abc.com will see the serve the error page. If you access the website using localhost / 127.0.0.1 - you will not see the error page |
Off | All user will see default error page by asp.net with details error information such as line number error and some of your coding highlight by the compiler where the error catch. |
On | No matter local or remote user will see the error page created by you (404.html / 500.html or AccessDenied.html) |
By Mohd Zulkamal
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
0 comments:
Post a Comment