user8033404
user8033404

Reputation:

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']?

Upvotes: 1

Views: 2765

Answers (2)

Patrick Hofman
Patrick Hofman

Reputation: 156978

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).

Upvotes: 1

mjwills
mjwills

Reputation: 23898

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.

Upvotes: 0

Related Questions