Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.