Here's a sample handler (global.asax):
void Application_Error(object sender, EventArgs e)
{
//get reference to the source of the exception chain
Exception ex = Server.GetLastError().GetBaseException();
EventLog.WriteEntry("MyWeb",
"MESSAGE: " + ex.Message +
"\nSOURCE: " + ex.Source +
"\nFORM: " + Request.Form.ToString() +
"\nQUERYSTRING: " + Request.QueryString.ToString() +
"\nTARGETSITE: " + ex.TargetSite +
"\nSTACKTRACE: " + ex.StackTrace,
EventLogEntryType.Error);
//Your other cool code here
}
--Peter
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:un*************@TK2MSFTNGP15.phx.gbl...
Thanks, When error occur, I redirect usr the a error page.
I want to show custom error message to user.
How can I cast the
Server.GetLastError() to the required exception type ?
"Ollie Riches" <ol**********@phoneanalyser.net>
¼¶¼g©ó¶l¥ó·s»D:eD*************@TK2MSFTNGP14.phx.gb l... What do you mean by 'statusCode'
Server.GetLastError returns a System.Exception object, you will have to
cast to the required exception type (if there is one).
HTH
Ollie Riches
"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:e2**************@TK2MSFTNGP15.phx.gbl...I use GenericErrorPage.aspx for the redirect page when some error occur.
I want to show some different according error statusCode .
How can I get error statusCode form Server.GetLastError()?