marcus
marcus

Reputation: 1

How does HttpApplication work in .net HttpRuntime?

Not sure whether HttpApplication works as a session mechanism. Once HttpApplication was created by HttpApplicationFactory via my first request, would HttpApplication be reused by HttpApplicationFactory via my second request? or renewed?

Upvotes: 0

Views: 407

Answers (1)

Markus
Markus

Reputation: 22501

From MSDN:

One instance of the HttpApplication class is used to process many requests in its lifetime. However, it can process only one request at a time. Thus, member variables can be used to store per-request data.

So the application object might have a long lifetime, but for different requests, different instances of the HttpApplication might be used.
This also implies that HttpApplication cannot be used as a Session mechanism. As I understand it, there are no reliable rules when the instances are reused - an instance can be reused for another user's request.
If you need Session memory, there is the Session object. If you need a Cache that is pertained across requests (and users), there is the Cache object that also allows to add rules on when cached items are removed.

Upvotes: 1

Related Questions