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)
{");
}
}
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)
{");
}
}