locked
How to configure httpModule so all errors go through it? RRS feed

  • Question

  • User1254222884 posted

    How do I configure my httpModule so that all errors go through it?

    Here's how I have it configured in my web.config (it handles begin_request, authorize_request, etc. just not application_error):

    in <system.webServer> I have
    <modules runAllManagedModulesForAllRequests="true">
       <add name="My Module Name" type="namespace.name"/>
        ...
    </modules>
    

    Like I said, the application.BeginRequest and other events fire fine. However, when I get an error not handled in other code, the application.error event does not fire.

    Any help TIA,

    Thursday, March 28, 2013 5:54 PM

All replies

  • User1254222884 posted

    Hmmm. We did have this working at one time.  Not sure when it quit working.  However, we did implement web-api recently and now we have a global.asax file (where we had none before).  Related?

    Thursday, March 28, 2013 6:07 PM
  • User1254222884 posted

    I don't think it's global.asax.  At any rate, all errors go through the HTTPModule on my developer machine (Windows 7 Ultimate), but not on the development Server or on the Production Servers (both Windows Server 2008 R2 Standard).  What do I need to set up to make the errors go through the httpModule on the servers?

    Friday, March 29, 2013 10:36 AM
  • User-2102303276 posted

    Hi,

    In Windows Server 2008 R2 Standard, the built in iis version is 7.5. The issue may be related to iis. So please have a look into the below article.

    http://bhaidar.net/cs/archive/2007/09/12/httpmodules-and-iis-7.aspx

     

    Monday, April 1, 2013 3:14 AM
  • User1254222884 posted

    The link should be: http://bhaidar.net/post/2007/09/13/HttpModules-and-IIS-7.aspx

    However, it doesn't solve the problem All other application events (and thus the httpModule) are working fine.  Just Errors are not working.

    Thanks,

    Wednesday, April 3, 2013 10:40 AM
  • User1254222884 posted

    Anyone?  Why does the server O/S version of IIS work differently than Windows 7?

    Monday, April 15, 2013 1:51 PM
  • User1254222884 posted

    Got this from Microsoft at: https://connect.microsoft.com/VisualStudio/feedback/details/782650/application-error-event-does-not-fire-on-windows-server-2008-r2-iis-7-5#tabs

    Quote:

    This looks like it's likely an environmental configuration issue given that it works locally on your developer machines but not on your target server. Please ask this question in the ASP.NET forums at http://forums.asp.net/ One thing to note is that if you're running the Visual Studio Development server locally (aka Cassini) then 404's for static file requests will result in the application error logic being hit, however this is not the case on IIS unless you have RAMMFAR (RunAllManagedModulesForAllRequests) enabled in your web.config file.

    :End Quote

    I checked, and our Web.config file already has:

    <modules runAllManagedModulesForAllRequests="true">

    Along with our add name for our httpModule. So, what am I missing?  Works fine on our developer machines (Windows 7, IIS7) but does not work on either our development or production servers (Windows 2008 R2, IIS7.5).

     

    Tuesday, April 23, 2013 10:37 AM
  • User1254222884 posted

    So, anyone have any ideas about what might be configured differently?  The web.config file is identical. I'm going through the IIS config dialogs now but so far have not found anything significantly different.

    ??

    Wednesday, May 15, 2013 1:15 PM
  • User-1002157272 posted

    1. Make sure it's registered properly.

    2. on application start, make sure you register it for the OnError event, within the global.asax.

    Viola. It will catch all application level errors. Anything outside of the AppDomain will not be caught though, but there wouldnt be much you could do about that within the app anyway.

    Sunday, July 7, 2013 1:47 AM