Wednesday, 15 February 2012

Custom error reporting in ASP.NET by using C# .NET

The title sound interesting right. So, in this post we are going to discuss about the custom error reporting in ASP.Net application.


                                                    source Code

We are going to use C#.Net code to trap and respond to errors when they occur in the ASP.net or rather I would say in our web application.

To trap the errors occurs we have written a separate class with the name ExceptionLog.cs, and we are using Global.asax to know about the error and trap through our ExceptionLog.cs class file and record the details into text file.

ExceptionLog.cs file:

In the class file we will write our logic to trap the errors occurred in application and logged that error details into text file.


The Log File:

As I had mentioned that the error details would get logged in textile with the name ErrorLog.txt




Global.asax

We will use the benefit of Global.asax to call error trap method on any Application error.

To know more about the Global.asax file you can visit below links:

1. http://en.wikipedia.org/wiki/Global.asax

2. http://msdn.microsoft.com/en-us/library/1xaas8a2(v=vs.71).aspx

3. http://www.dotnetcurry.com/ShowArticle.aspx?ID=126

4. http://support.microsoft.com/kb/306355

So here is the piece of code to catch the error occurred in the application and logged those into text file through our custom error logged class.



Hope it will be useful for you!!

Feel free to provide your comments and any suggestions!!

~jawed

Saturday, 11 February 2012

My Name in the list of winners at C-sharp corner for the month of December, 2011.


I was unable to express my happiness when I saw my name in the list of winners. 
While posting any article on http://www.c-sharpcorner.com ,I never thought that my name would get listed over there with in 2 months .

But now this became true. All this happen due to all my readers’ comments and suggestion which gave me courage to write more and more.
Thanks to all my readers, http://www.c-sharpcorner.com and mentors who encourage me share my knowledge and experience.

These kinds of encouragement provide me a better and nice path to share my knowledge/experience with much bigger audiences. 

Lists of winners:


Thanks,
Md. jawed