HttpContext.Current.ApplicationInstance.Application vs HttpContext.Current.Application

If I want to keep some objects for sharing across pages and session, which should I use?

HttpContext.Current.ApplicationInstance.Application

or HttpContext.Current.Application

.

I used HttpContext.Current.Application

but just messed up between the two.

+3


source to share


2 answers


They both refer to the same thing, HttpApplicationState



+5


source


Application

and ApplicationInstance.Application

- two versions of the same HttpApplicationState object.

In HttpApplicationState, the link is:

A single instance of the HttpApplicationState class is created the first time a client requests any resource URL from a specific ASP.NET Application Virtual Directory. A separate, separate instance created for each ASP.NET application on the web server. A link to each instance is then opened through the embedded Application object.



Summarizing:

  • Application

    the object is global to the web server.
  • ApplicationInstance.Application

    the object is local to the application to which the request belongs. (such as a site or virtual directory application)

This is explained in this post.

+3


source







All Articles