Active Server Pages Programming (ASP)/Global Error Handling

Advertisement


Question
I would like to ask how do i do something like a global error handling function in ASP .NET . This function will be called everytime an error occurs in the script. I did a search on the web and found that there is actually this function called 'Application_Error' and have tried it out.

I'm trying to logged all errors that occurs on my webpage to a database to facilitate forensic debugging. Previously in ASP 2.0 , i can logged all the error information (eg. Line number, Source, Descriptions) into my ErrLog Database, but now i've found out that the errors in ASP .NET is very different. The errors (or they called it exceptions) they give is very different. Looks like those Object-Oriented kind of error message.

Is it possible for .NET to have the same kind of error logging function like ASP 2.0 (eg giving me the line at which the error occurred) ?

Or if possible , can you explain to me how to debug the error messages in .NET ?

Let me know if you don't understand my questions.

Thanks!

Answer
Hi

Sorry for the delay in reply...

Here is the simple code sample stores the error into a text file... you can modify and store into the db

in .net you have better control on error handling.. You can set in your web.config to handle the error or as you said application_error in global.asax

In this sample it talks how to store into a text file.

http://www.codeproject.com/aspnet/createlogfiles.asp


Here is the most advanced version of error handling..

http://www.codeproject.com/csharp/NotSoSimpleErrorLog.asp

Happy programming!

-Srini

Active Server Pages Programming (ASP)

All Answers


Answers by Expert:


Ask Experts

Volunteer


Srini Nagarajan

Expertise

I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience

Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.

©2012 About.com, a part of The New York Times Company. All rights reserved.