473,383 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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

}

}

May 8 '06 #1
0 1287

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nicholas Irving | last post by:
Hi all, I am having an issue with one of my HttpModules where I cannot get the application path on Init. What I would like to do is to the following public class wherefrom : IHttpModule {...
5
by: Andrew Lippitt | last post by:
What gaurantees are there in the way of which thread the events are called from. I've seen: Thread A Begin Thread B Begin Thread A End Thread A End That seems to indicate that Begin and End...
6
by: Andy G | last post by:
I am trying to implement the global error handling described on this page... http://www.dotnetdevs.com/articles/GlobalErrorHandling.aspx I'm a VB person and don't understand much of C# when it...
6
by: Simone Busoli | last post by:
Hello, I am trying to understand when IHttpModule.Dispose method is called. Is it called when the Application is disposed, or when the request ends? If I want to make an object Application-wide...
5
by: Richard | last post by:
I've developed a small ASPX template framework (based on Chun Li's article on CodeProject: http://www.codeproject.com/aspnet/headerfooter.asp#xx849313xx) which uses a IHttpModule to apply...
0
by: John | last post by:
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...
3
by: trullock | last post by:
Hi, Ive written a URLRewriter IHttpModule which all works fine. I've come to make a change to it which involves deciding where to redirect based on what role a user is in....
8
by: =?Utf-8?B?UGhpbGlw?= | last post by:
When is the IHttpModule Dispose driven ?....at application recycle time ? I developed a test HttpModule to trace INIT, BeginRequest, EndRequest and Dispose....and the Dispose never gets driven. ...
1
by: Eric Goforth | last post by:
Hello, I found a C# example on the web that used an httpmodule. I've translated it to VB.NET and the website compiles fine, but when I build the website the iHttpModule doesn't compile, I can't...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.