Hi,
I implemented a httpmodule to handle exceptions.
But when I tested it in a web application, the httpmodule code does not
seem to execute. I dont have VS.Net to set breakpoints and debug. So I
commented all but four lines in the httpmodule which just writes out
the exception message. This is what I have in the httpmodule.
public void Init(System.Web.HttpApplication Application)
{
Application.Error += new EventHandler(OnError);
}
public void Dispose()
{
}
protected virtual void OnError(object sender, EventArgs args)
{
HttpApplication app = ((HttpApplication)(sender));
HttpContext.Current.Response.Write(app.Server.GetLastError().Message);
HttpContext.Current.Response.Flush();
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.End();
}
I added a reference to this dll in my web application and changed the web.config to include this,
<httpModules>
<add name="handleexceptions" type="httpmoduleapp.handleexceptions,
httpmoduleapp" />
</httpModules>
But
still when I test a page that throws an exception, I dont see the
exception.message that I am writing out in the httpmodule. Instead the
page is redirected to the default error page that is set in the
web.config file even though I clear the error in the httpmodule. It
looks like the httpmodule is not hooked up properly. Can any one tell
me what am I missing here.
Thanks.