How come I can not catch IHTTPModule Error Event???

J

John

I am writing a custom httpmodule, I can catch BeginRequest, EndRequest
event,
But I can not catch Error event, I tried throwing an error from my Web
Service, creating a security exception (by login the web service with
invalid user name 3 times)
Did I do any thing wrong here? (VS2005)
Please advice.
Thanks in advance.
John


using System;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Security;

public class MyModule : IHttpModule {
public void Init(HttpApplication app) {

Trace.WriteLine("public void Init(HttpApplication app) {");

app.Error += (new EventHandler(this.Application_OnError));
app.BeginRequest += (new
EventHandler(this.Application_BeginRequest));
app.EndRequest += (new EventHandler(this.Application_EndRequest));
Trace.WriteLine("public void Init(HttpApplication app) { end");

}
public String ModuleName
{
get { return "HelloWorldModule"; }
}


public void Dispose() {}
private void Application_BeginRequest(Object source, EventArgs e)
{
Trace.WriteLine("Application_BeginRequest(Object source, EventArgs
e)");
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<h1><font color=red>HelloWorldModule:
Beginning of Request</font></h1><hr>");
}

// Your EndRequest event handler.
private void Application_EndRequest(Object source, EventArgs e)
{
Trace.WriteLine("Application_EndRequest(Object source, EventArgs
e)");
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<hr><h1><font color=red>HelloWorldModule:
End of Request</font></h1>");
}


private void Application_OnError(object sender, EventArgs args)
{
Trace.WriteLine("Application_OnError(Object source, EventArgs e)");
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
context.Response.Write("<h1><font color=red>ON
ERROR</font></h1><hr>");

Trace.WriteLine("static void OnError(object sender, EventArgs args)
{");

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top