views:

52

answers:

1

I have some doubt over HttpModule and HttpHandler Please help me to clarify

1)In HttpModule I have noticed methods Init called only once . context_BeginRequest and context_EndRequest etc method calling for each request. Is it guaranteed that for a module Init will call once for different users(or different request) and BeginRequest etc will call every time for different users (or different request) ?

2)Is there any possibility that Application_Start(global.asax) can run more than once because there may be more than one application object

3) Since application object can be different (from application pool) In this case how Application data is shared between different users?

4) In HttpHandler ProcessRequest method will call for each request (or for each user).

Thanks Ritu

+1  A: 

"Is it guaranteed that for a module Init will call once for different users(or different request) and BeginRequest etc will call every time for different users (or different request)?"

The init method will be called when the app pool starts / when the application is started for the first time. This is when the module is loaded.

The BeginRequest method is called every time the application starts handling a new HTTP request.

*"2)Is there any possibility that Application_Start(global.asax) can run more than once because there may be more than one application object"*

There is not more than one application in a particular folder. IIS doesn't work that way. Only one global.asax per application, and Application_Start will only be called once for each application unless the app pool is reset.

"3) Since application object can be different (from application pool) In this case how Application data is shared between different users?"

Depends where you're storing this application data and what you're using to retrieve it. I'm not sure what you mean about this. Session data should be scoped to an individual application (certainly for in-process session state server, and if properly configured also for out-of-process session state server)

"4) In HttpHandler ProcessRequest method will call for each request (or for each user)."

Yes, but only for requests which are mapped to your handler. Conversely, HttpModule can be called for ALL requests.

Steve
Thanks Steve for your reply.In 3) My doubt is as there may be different application object ( from HttpApplication factory pool) for different users Suppose I have stored Application["Key"]= some data in Application_Start and if Application object will change for other user.Will other user able to get these value if yes how ?
Ritu
Hi Steve,http://www.dominicpettifer.co.uk/Blog/41/ihttpmodule-gotchas---the-init---method-can-get-called-multiple-timesAs per link we can have multiple init call
Ritu