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 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


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:





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!!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s