Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / ASP

Getting the last error in a custom error page

0.00/5 (No votes)
5 Jan 2011CPOL 7.3K  
Would it not be easier to capture your Error in your Global.aspx page?void Application_Error(object sender, EventArgs e){ Exception lastError = Server.GetLastError(); if (lastError == null) { ErrorLog(An error occurred, but no error information is available); ...
Would it not be easier to capture your Error in your Global.aspx page?

C#
void Application_Error(object sender, EventArgs e)
{
    Exception lastError = Server.GetLastError();
    if (lastError == null)
    {
       ErrorLog("An error occurred, but no error information is available");
    }
    else
    {
       ErrorLog(lastError.ToString());
    }
}


Regards

License

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