Name:
Location: Rowland Heights, California, United States

Tuesday, March 29, 2005

Catch All Error Trap for ASP.NET

Trying to trap every error in code if virtually impossible - but in ASP.NET it's as easy at 1, 2 and 3!

Generic error trapping is important when it comes to Web Applications so you know something wrong is happening with your web site.

In most cases you want to put your code in the Application_Error event handler of the Global.asax file. There is plenty of information that you can access in that method.

For starters, you can check the sender and e objects sent as parameters. Those can provide some useful information. You can also call Server.GetLastError(). Another thing to do is create a NameValueCollection Object and gather all the environment variables.

After you've done all this you can either save it to a file, log it in the event log, email it to yourself, etc...

Hope this helps you!!!

0 Comments:

Post a Comment

<< Home