As the title says - how do I disable all of the ASP.NET unhandled errors appearing in the event log? Cant see anything obvious in IIS / the web.config...
1 Answers
The easiest way I can think of right now is through a code-based solution, not web.config. In the global.asax file for your application, you can add an Application_Error event handler. In this, you can do whatever you want to do to log the error (or not...) and then redirect to an appropriate error page. Call Context.ClearError()
before redirecting, and none of the standard ASP.Net unhandled excpetion stuff will kick in. This is not a pretty way to handle this though, so hopefully somebody else has a better answer.
A simple global.asax that does only this functionality would look like:
<%@ Application Language="C#" %>
<%@ Import namespace="System.Diagnostics" %>
<script runat="server">
protected void Application_Error(object src, EventArgs e)
{
Exception ex = Server.GetLastError();
// do whatever you want to the error itself (ex.Message, etc.)
// ####
// clear out the ASP.Net error
Context.ClearError();
// redirect to an error page
Response.Redirect("errorpage.aspx");
}
</script>
With all that being said, there has to be a way to do this using the web.config healthMonitoring section, I just can't figure out how to say "turn off logging for all events".

- 11,194
- 1
- 30
- 36