Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 03, 2009 04:10 PM by leila
Jan 27, 2009 11:16 AM|LINK
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.
Jan 27, 2009 12:38 PM|LINK
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 (:
Jan 27, 2009 01:00 PM|LINK
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.
Feb 03, 2009 04:10 PM|LINK
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).