Hi EveryOne
I am working on a project, where I have to handle error handling globally using Global.asax function
"void Application_Error(object sender, EventArgs e) "
My code in the Global.asax file is like this:
void Application_Error(object sender, EventArgs e)
{
DBUtill dbobj = new DBUtill();
dbobj.App_Error();
}
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("'", ""));
ScalarSql(sql);
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Redirect("~/Error.aspx");
}
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.