locked
Error Module getting called on 404's RRS feed

  • Question

  • User-852409647 posted
    I setup an error httpmodule that ties into OnError.  The problem is that it's being called for 404's and other nonsense.  Everything returns status code 200 so that's useless to check.  I really only want this called for real 500 errors (or specifically what used to be 500;100 errors in Classic ASP if that's possible).

    I'm resorting to the following to not use my special logging for 404's and have them go to the proper custom errors page I defined:

                if (exception != null && exception.GetType() == typeof(HttpException) && exception.TargetSite.Name!="CheckVirtualFileExists")
                {
                    return;
                }

    I'd rather have a cleaner solution than using reflection to check vs a hardcoded string.  I'd also like to extend this more neatly to avoid logging 401 permission errors, etc.
    Friday, May 19, 2006 6:30 PM

All replies

  • User-852409647 posted

    I found a better way.  I had simply not case the exception to HttpException so that's why I couldn't check for the 404.

                if (exception != null && exception.GetType() == typeof(HttpException) && (exception as HttpException).GetHttpCode()==404)
                {
                    return;
                }

    Monday, August 28, 2006 10:01 PM