Last post May 07, 2007 11:26 PM by Rex Lin - MSFT
May 06, 2007 08:34 AM|zhihao|LINK
May 06, 2007 08:51 PM|bitmask|LINK
Yes, the Init event fires once when the module is first instantiated.
Remember, too, that there can be multiple instance of an HttpModule at work in an ASP.NET application.
May 06, 2007 09:31 PM|zhihao|LINK
May 06, 2007 11:37 PM|bitmask|LINK
ASP.NET keeps a pool of HttpApplication instances around to concurrently service multiple requests. Each HttpApplication object will have it's own suite of HttpModules, so if there are 10 HttpApplication objects active, you'll have 10 instance of your module.
Here is some background info:
May 07, 2007 11:06 PM|zhihao|LINK
Thanks for your reply!
I also have a question about HttpModule: If I call Server.Transfer("B.aspx") in A.aspx, why I can't catch the request of B.aspx in HttpModule? Whether the B.aspx will not pass the HttpModule?
May 07, 2007 11:26 PM|Rex Lin - MSFT|LINK
Thats because your already within the bounds of the asp.net request pipeline
and by using transfer your effectively saying you want to stay within the
pipeline, all your really doing is transferring the page request to a
sub-request not intiating a new one. Redirtect takes you out of the asp.net
pipeline and forces a new request, hence resulting in the behaviour you
Server.Transfer executes the page being requested without going back to the
client. It's a more direct, faster way to send a client a page. Here's a
If a client requests page1 of your website and then posts back and you
execute a Response.Redirect to page2 the client browser is sent new code
that tells it to go to page2. Therefore in this scenario your handler gets
the correct page because the client has requested it.
If a client requests page1 of your web then posts back and you execute a
Server.Transfer to page2 the client browser is not contacted at all. Instead
the web server sends page2 to the client as if page2 is page1. The client
doesn't even know it's on a different page.
I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance