Click here to Skip to main content
13,045,285 members (51,874 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi EveryOne

I am working on a project, where I have to handle error handling globally using Global.asax function
[__b__]"void Application_Error(object sender, EventArgs e) "

My code in the Global.asax file is like this:
void Application_Error(object sender, EventArgs e)
       // Code that runs when an unhandled error occurs
       DBUtill dbobj = new DBUtill(); // This is my class for all sorts of
                                      // functionality for my project
       dbobj.App_Error();  // This is my function where i am saving the error
                           // To a database.

From one of my pages in the load event i am throwing unhandled exception just to check whether it is working or not. like below
throw (new ArgumentNullException());

For the purpose of easiness i am including my App_Error function also
public void App_Error()
       Exception ex = HttpContext.Current.Server.GetLastError().GetBaseException();
       string sql = string.Format("insert into tbl_ApplicationErrors (ErrorType,ErrorPage,ErrorDetail) values ('{0}','{2}','{2}')", ex.Source.Replace("'", ""), HttpContext.Current.Request.Url.ToString().Replace("'", ""), ex.ToString().Replace("'", ""));

By the first and second time it went right and also inserted values in the database, I mean the Application_Error function fired by the first and second time, but onward it is not working.

What should be the problem, each and every solution will be appreciated.
Posted 22-Feb-11 19:02pm
Updated 22-Feb-11 20:01pm
Sandeep Mewara 23-Feb-11 2:01am
Did you tried to look at the execution cycle using DEBUGGER? Where and how it's going?
TanzeelurRehman 23-Feb-11 2:48am
First of All Thanks for your reply

Should i run the whole website through debugging.
TanzeelurRehman 23-Feb-11 3:15am
Thankyou Sandeep Mewara, Basically there was error on DataAccess Layer, It got solved
Sandeep Mewara 23-Feb-11 4:01am
:) Good to know.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Answering it to remove from Unanswered list.

OP resolved the same by himself. There was an issue at DataAccess layer which got resolved on DEBUGGING.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 23 Feb 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100