static void

ASP Errors

See log ASP errors with log4net or log ASP errors with health monitoring.

Errors

Error Logging

NB: Web.config customErrors/@defaultRedirect can't log (implicit Server.ClearError)

Global.asax Application_Error. This can obviate the customErrors/@defaultRedirect directive if you Server.ClearError() and redirect. See an example with log4net or an example with asp 2 health monitoring.

In ASP 2, put WebEventProviders in the web.config. (Quickstart, msdn)

"All Errors" doesn't pick up handled errors. Including those handled by Server.ClearError in Global.Application_Error

Event Log

ASP.Net cannot by default create a event log source (unless you use the ASP.Net 2 Health Monitoring source). (KB- either create a registry entry for it, or use System.Diagnostics.EventLogInstaller).

Async Disconnect Errors (.net 4.5)

In .net 4.5 you can use async Task actions. Because they are async, disconnects trigger the standard escalation policy to terminate the process. Opps. Put this in Global.asax Application_Start:

//log and swallow the async disconnect errors "The remote host closed the connection. The error code is 0x80070057."
TaskScheduler.UnobservedTaskException += (sender, e) =>
{
    e.SetObserved();
    Trace.TraceError(e.Exception.ToString());
};