1

Asp.Net has an erroneous behavior of casting exception if connection is dropped by browser (e.g. tab is closed). It casts two exception in this case that are not really anything we should worry about or log it (or at least I don't want to see this "noise" in the logs).

There is a bigger discussion of the issue here. This is my solution to filtering out these exceptions (in Application_Error) that seems to work.

private static bool IsAspNetBugException(Exception exception)
{
    return
        (exception is TaskCanceledException || exception is OperationCanceledException) 
        &&
        exception.StackTrace.Contains("System.Web.HttpApplication.ExecuteStep");
}

What I am wondering if this is "good enough" and won't hide any real exceptions. Not the world's most robust code, but have not found anything better to figure out if this is an exception from Asp.Net itself than reading stack trace.

Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207

0 Answers0