using System.Diagnostics;
protected void Application_Error(Object sender, EventArgs e)
{
string errMsg = " <link rel=\ " stylesheet\ " href=\ " / ThePhile / Styles / ThePhile.CSS\ " > " ;
errMsg += " <h1>Application Error</h1><hr/>An unexpected error has occurred in this Application. The system " +
" administrators have been notified. Please feel free to contact us with the information " +
" surrounding this error.<br/> " +
" The error occurred in: " + Request.Url.ToString() + " <br/> " +
" Error Message: <font class=\ " ErrorMessage\ " > " + Server.GetLastError().Message.ToString() + " </font><hr/> " +
" <b>Stack Trace:</b><br/> " +
Server.GetLastError().ToString();
Response.Write( errMsg );
if ( ! EventLog.SourceExists( " ThePhile.COM " ))
{
EventLog.CreateEventSource( " ThePhile.COM " , " Application " );
}
EventLog.WriteEntry( " ThePhile.COM " , Server.GetLastError().Message, EventLogEntryType.Error);
Server.ClearError();
}
web.config
protected void Application_Error(Object sender, EventArgs e)
{
string errMsg = " <link rel=\ " stylesheet\ " href=\ " / ThePhile / Styles / ThePhile.CSS\ " > " ;
errMsg += " <h1>Application Error</h1><hr/>An unexpected error has occurred in this Application. The system " +
" administrators have been notified. Please feel free to contact us with the information " +
" surrounding this error.<br/> " +
" The error occurred in: " + Request.Url.ToString() + " <br/> " +
" Error Message: <font class=\ " ErrorMessage\ " > " + Server.GetLastError().Message.ToString() + " </font><hr/> " +
" <b>Stack Trace:</b><br/> " +
Server.GetLastError().ToString();
Response.Write( errMsg );
if ( ! EventLog.SourceExists( " ThePhile.COM " ))
{
EventLog.CreateEventSource( " ThePhile.COM " , " Application " );
}
EventLog.WriteEntry( " ThePhile.COM " , Server.GetLastError().Message, EventLogEntryType.Error);
Server.ClearError();
}
<customErrors mode="RemoteOnly" defaultRedirect="error.aspx"/>