Click Here To Get Amazing Facebook Profile Covers,Status Messages

How to set Custom error pages in asp.net using web.config

In ASP.NET you can handle page level errors using OnError method of page object or Application level errors using Application_Error method.

If you want to specify custom error pages then you can do this by making changes in web.config, configuration file for

asp.net.By default there is an entry in customErrors section of your web.config file

RemoteOnly value of mode attribut makes your application to display complete error page with compilation

info and stack trace details for local users.For remote user it will display custom error page if specified if custom error

page is not specified it will simply say that error has occured without showing any detail.

other two values mode attribute can have is On and Off.

When mode is on and you have specified custom error page then it will be shown to all users.if custom error page is not specified then it will simply notify without any details to all users including local user.

When mode is off it will show complete error to all users. Even if you have specified custom error page then it will not be shown to any users.

User is not interested in complete error and at the same time showing simply that an error has occured is not enough.So web developers use custom error pages for regretting or diplaying some meaning full info to user.

defaultRedirect attribute of customErrors tag can be used to dispaly a default error page to users.mode can be remote only also.

In more granular approach you may want to display a particular error page for a given type of error and a default page for

rest of errors.Error sub tag of customErrors tag can be used for this.

The path for error pages can be relative or absolute.

Your rating: None Average: 5 (1 vote)