简体   繁体   中英

Application object in ASP.NET

I was reading a article saying " the first time a user request a page that resides in an application's directory, ASP.NET initializes the application. During that process, ASP.NET creates an application object, application state object and a cache object.

My questions are:

  1. Let's say I have many users request a page from the application, how many application state objects are created by the application? just one or many? will new application state object be created for every new user? or all users share the same objects?

  2. If there is only one application object created, how can the application know which Session belongs to which users? For examples, Michael requests a page, nd setting Session["name']= "Michael", Sarah also requests a page and setting Session["name']= "Sarah", so how can the application what's the value of Session["name']?

There is just one Application object per application, which is shared by all users. The Session object is not shared between sessions (and thus users).

The Session state is not part of the Application context. ASP.NET knows which session belongs to who (based on session cookies for example).

For Sessions, see How the session work in asp.net? . In short - it identifies the session via a cookie.

For Application / Application State, there is one object. See https://msdn.microsoft.com/en-us/library/ms178594.aspx for more details.

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