locked
Custom HttpModule RRS feed

  • Question

  • User-1097933300 posted

    Hi everyone,

    I have created a custom http module. In this class I've got an Init method that initializes the OnError event handler. It all works fine when I run the website from with the Visual Studio environment, that is when an error is raised, the OnError method of the module get fired and it shows me a page I've created to show some sort of information about the error.
    However, the problem is that when I deploy the site, the error is shown as a .Net error and not on the custom error page, it seems that the module is not known as the OnError methos does not fire.

    I have added stuff to my web.config file.
    I also have manualy added a managed module to the IIS and config settings to the web.config in the System.WebServer section.
    Afterall, it doesn't work.

    Can anyone tell me what I'm missing in configuration or anything else that prevnets the module to work on the deployed website?!

    Thanks in advance for your help.

    Tuesday, January 27, 2009 7:16 AM

Answers

  • User-916962509 posted

     Instead of using custom HTTP modules, why not just use the <customErrors> section of web.config? You can redirect the user to a page of your choosing when any unhandled exception is thrown, then on that page, you can use Server.GetLastError() and Server.ClearError() to find out what the error was and display some information to the user.

    It is a lot easier than using custom http modules for error handling (:

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 27, 2009 8:38 AM

All replies

  • User-916962509 posted

     Instead of using custom HTTP modules, why not just use the <customErrors> section of web.config? You can redirect the user to a page of your choosing when any unhandled exception is thrown, then on that page, you can use Server.GetLastError() and Server.ClearError() to find out what the error was and display some information to the user.

    It is a lot easier than using custom http modules for error handling (:

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 27, 2009 8:38 AM
  • User-1097933300 posted

    well, to be honest I've tried that butfor some reason the server.GetLastError is always null even though an error is raised.

    anyway, I came across an article about using http modules for error handling and I'm really intrested to make it work.
    but thanks for your suggestion.

    Tuesday, January 27, 2009 9:00 AM
  • User-1097933300 posted

    GOT IT!!!!

    If anyone is using an httpmodule for error handling, note that you need to clear the error before actually make use of the it (in my case redircting to an error page and displaying the error message).

    Tuesday, February 3, 2009 12:10 PM