Name

Application

Synopsis

HttpApplicationState = Context.Application

Returns the current Application state object.

Parameters

HttpApplicationState

An HttpApplicationState object that will receive the value of the property.

Example

The example sets an application value using the Application instance exposed by the Page class and gets the instance from Context. Finally, it displays the newly set value by using the HttpApplicationState instance retrieved from the Context object (proving they are the same object):

Sub Page_Load(  )
    Dim App as HttpApplicationState
    Page.Application("Test")="Value"
    App = Context.Application
    Message.Text = App("Test")
End Sub

Notes

Often, you will use the copy of Application from the Page class. However, for objects not derived from Page (for instance, HttpHandlers and HttpModules) this is a convenient way to access the Application state.

Do not confuse this property, which returns an instance of type HttpApplicationState, with the ApplicationInstance property, which returns an instance of type HttpApplication.

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.