简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM