65.9K
CodeProject is changing. Read more.
Home

Getting the last error in a custom error page

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Jan 4, 2011

CPOL
viewsIcon

7261

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