Sideway
output.to from Sideway
Draft for Information Only

Content

Application Object
 HttpApplicationState Class
  Methods
  Properties
  Explicit Interface Implementations
 HttpApplication Class
  Constructors
  Methods
  Properties
  Events
  Explicit Interface Implementations
 Remarks
 Source/Reference

Application Object

The ASP Application object  is supported by ASP.NET through HttpApplicationState Class and HttpApplication Class. Application object of ASP.NET is related to the manipulation of information about entire web application for all clients on the server.

A single instance of an HttpApplicationState class is created the first time a client requests any URL resource from within a particular ASP.NET application virtual directory. In other words, an HttpApplicationState class is not a global application object. A reference to each instance of the System.Web.HttpResponseState class is then exposed via the intrinsic Application object.

An HttpApplicationState class defines the methods, properties, and events that are common to all application objects in an ASP.NET application. This class is the base class for applications that are defined by the user in the Global.asax file. Instances of the HttpApplication class are created in the ASP.NET infrastructure, not by the user directly. 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. ASP.NET introduces the unique Application_OnStart and Application_OnEnd "events" for compatibility with classic ASP. These "events" are executed only once in the lifetime of an application and not for every application instance. Therefore, if you change non-static members in these methods, you affect only one application instance and not all instances. 

HttpApplicationState Class

Methods

Method Description
Add(String, Object) Adds a new object to the HttpApplicationState collection.
BaseAdd(String, Object) Adds an entry with the specified key and value into the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseClear() Removes all entries from the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseGet(Int32) Gets the value of the entry at the specified index of the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseGet(String) Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseGetAllKeys() Returns a String array that contains all the keys in the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseGetAllValues() Returns an Object array that contains all the values in the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseGetAllValues(Type) Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseGetKey(Int32) Gets the key of the entry at the specified index of the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseHasKeys() Gets a value indicating whether the NameObjectCollectionBase instance contains entries whose keys are not null. (Inherited from NameObjectCollectionBase)
BaseRemove(String) Removes the entries with the specified key from the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseRemoveAt(Int32) Removes the entry at the specified index of the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseSet(Int32, Object) Sets the value of the entry at the specified index of the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
BaseSet(String, Object) Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
Clear() Removes all objects from an HttpApplicationState collection.
Contents.Remove Remove or delete an item from the Contents collection of Application object.
Contents.RemoveAll Remove or delete all items from the Contents collection of Application object.
Equals(Object) Determines whether the specified object is equal to the current object. (Inherited from Object)
Get(Int32) Gets an HttpApplicationState object by numerical index.
Get(String) Gets an HttpApplicationState object by name.
GetEnumerator() Returns an enumerator that iterates through the NameObjectCollectionBase. (Inherited from NameObjectCollectionBase)
GetHashCode() Serves as the default hash function. (Inherited from Object)
GetKey(Int32) Gets an HttpApplicationState object name by index.
GetObjectData(SerializationInfo, StreamingContext) Implements the ISerializable interface and returns the data needed to serialize the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
GetType() Gets the Type of the current instance. (Inherited from Object)
Lock() Locks access to an HttpApplicationState variable to facilitate access synchronization.
MemberwiseClone() Creates a shallow copy of the current Object. (Inherited from Object)
OnDeserialization(Object) Implements the ISerializable interface and raises the deserialization event when the deserialization is complete. (Inherited from NameObjectCollectionBase)
Remove(String) Removes the named object from an HttpApplicationState collection.
RemoveAll() Removes all objects from an HttpApplicationState collection.
RemoveAt(Int32) Removes an HttpApplicationState object from a collection by index.
Set(String, Object) Updates the value of an object in an HttpApplicationState collection.
ToString() Returns a string that represents the current object. (Inherited from Object)
Unlock() Unlocks access to an HttpApplicationState variable to facilitate access synchronization.

Properties

Property Description
AllKeys Gets the access keys in the HttpApplicationState collection.
Contents (Collection) Gets a reference to the HttpApplicationState object.
Count Gets the number of objects in the HttpApplicationState collection.
ICollection.IsSynchronized Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe). (Inherited from NameObjectCollectionBase)
ICollection.SyncRoot Gets an object that can be used to synchronize access to the NameObjectCollectionBase object. (Inherited from NameObjectCollectionBase)
IsReadOnly Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only. (Inherited from NameObjectCollectionBase)
Item[Int32] Gets a single HttpApplicationState object by index.
Item[String] Gets the value of a single HttpApplicationState object by name.
Keys Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance. (Inherited from NameObjectCollectionBase)
StaticObjects (Collection) GetsGets all objects declared by an <object> tag where the scope is set to "Application" within the ASP.NET application.

Explicit Interface Implementations

Interface Description
ICollection.CopyTo(Array, Int32) Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from NameObjectCollectionBase)

HttpApplication Class

Constructors

Constructor Description
HttpApplication() Initializes a new instance of the HttpApplication class.

Methods

Method Description
AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) Adds the specified AcquireRequestState event to the collection of asynchronous AcquireRequestState event handlers for the current request.
AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified AcquireRequestState event to the collection of asynchronous AcquireRequestState event handlers for the current request.
AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified AuthenticateRequest event to the collection of asynchronous AuthenticateRequest event handlers for the current request.
AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified AuthenticateRequest event to the collection of asynchronous AuthenticateRequest event handlers for the current request.
AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified AuthorizeRequest event to the collection of asynchronous AuthorizeRequest event handlers for the current request.
AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified AuthorizeRequest event to the collection of asynchronous AuthorizeRequest event handlers for the current request.
AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified BeginRequest event to the collection of asynchronous BeginRequest event handlers for the current request.
AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified BeginRequest event to the collection of asynchronous BeginRequest event handlers for the current request.
AddOnEndRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified EndRequest event to the collection of asynchronous EndRequest event handlers for the current request.
AddOnEndRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified EndRequest event to the collection of asynchronous EndRequest event handlers for the current request.
AddOnLogRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified LogRequest event to the collection of asynchronous LogRequest event handlers for the current request.
AddOnLogRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified LogRequest event to the collection of asynchronous LogRequest event handlers for the current request.
AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) Adds the specified MapRequestHandler event to the collection of asynchronous MapRequestHandler event handlers for the current request.
AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified MapRequestHandler event to the collection of asynchronous MapRequestHandler event handlers for the current request.
AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) Adds the specified PostAcquireRequestState event to the collection of asynchronous PostAcquireRequestState event handlers for the current request.
AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostAcquireRequestState event to the collection of asynchronous PostAcquireRequestState event handlers for the current request.
AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified PostAuthenticateRequest event to the collection of asynchronous PostAuthenticateRequest event handlers for the current request.
AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostAuthorizeRequest event to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.
AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified PostAuthorizeRequest event to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.
AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostAuthorizeRequest to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.
AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler) Adds the specified PostLogRequest event to the collection of asynchronous PostLogRequest event handlers for the current request.
AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostLogRequest event to the collection of asynchronous PostLogRequest event handlers for the current request.
AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) Adds the specified PostMapRequestHandler event to the collection of asynchronous PostMapRequestHandler event handlers for the current request.
AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostMapRequestHandler event to the collection of asynchronous PostMapRequestHandler event handlers for the current request.
AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) Adds the specified PostReleaseRequestState event to the collection of asynchronous PostReleaseRequestState event handlers for the current request.
AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostReleaseRequestState event to the collection of asynchronous PostReleaseRequestState event handlers for the current request.
AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) Adds the specified PostRequestHandlerExecute event to the collection of asynchronous PostRequestHandlerExecute event handlers for the current request.
AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostRequestHandlerExecute event to the collection of asynchronous PostRequestHandlerExecute event handlers for the current request.
AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) Adds the specified PostResolveRequestCache event to the collection of asynchronous PostResolveRequestCache event handlers for the current request.
AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostResolveRequestCache event to the collection of asynchronous PostResolveRequestCache event handlers for the current request.
AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) Adds the specified PostUpdateRequestCache event to the collection of asynchronous PostUpdateRequestCache event handlers for the current request.
AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PostUpdateRequestCache event to the collection of asynchronous PostUpdateRequestCache event handlers for the current request.
AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) Adds the specified PreRequestHandlerExecute event to the collection of asynchronous PreRequestHandlerExecute event handlers for the current request.
AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified PreRequestHandlerExecute event to the collection of asynchronous PreRequestHandlerExecute event handlers for the current request.
AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) Adds the specified ReleaseRequestState event to the collection of asynchronous ReleaseRequestState event handlers for the current request.
AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified ReleaseRequestState event to the collection of asynchronous ReleaseRequestState event handlers for the current request.
AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) Adds the specified ResolveRequestCache event handler to the collection of asynchronous ResolveRequestCache event handlers for the current request.
AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified ResolveRequestCache event handler to the collection of asynchronous ResolveRequestCache event handlers for the current request.
AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) Adds the specified UpdateRequestCache event to the collection of asynchronous UpdateRequestCache event handlers for the current request.
AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) Adds the specified UpdateRequestCache event to the collection of asynchronous UpdateRequestCache event handlers for the current request.
CompleteRequest() Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.
Dispose() Disposes the HttpApplication instance.
Equals(Object) Determines whether the specified object is equal to the current object. (Inherited from Object)
GetHashCode() Serves as the default hash function. (Inherited from Object)
GetType() Gets the Type of the current instance. (Inherited from Object)
GetVaryByCustomString(HttpContext, String) Provides an application-wide implementation of the VaryByCustom property.
Init() Executes custom initialization code after all event handler modules have been added.
MemberwiseClone() Creates a shallow copy of the current Object. (Inherited from Object)
ToString() Returns a string that represents the current object. (Inherited from Object)

Properties

Property Description
Application Gets the current state of an application.
Context Gets HTTP-specific information about the current request.
Events Gets the list of event handler delegates that process all application events.
Modules Gets the collection of modules for the current application.
Request Gets the intrinsic request object for the current request.
Response Gets the intrinsic response object for the current request.
Server Gets the intrinsic server object for the current request.
Session Gets the intrinsic session object that provides access to session data.
Site Gets or sets a site interface for an IComponent implementation.
User Gets the intrinsic user object for the current request.

Events

Event Description
AcquireRequestState Occurs when ASP.NET acquires the current state (for example, session state) that is associated with the current request.
AuthenticateRequest Occurs when a security module has established the identity of the user.
AuthorizeRequest Occurs when a security module has verified user authorization.
BeginRequest Occurs as the first event in the HTTP pipeline chain of execution when ASP.NET responds to a request.
Disposed Occurs when the application is disposed.
EndRequest Occurs as the last event in the HTTP pipeline chain of execution when ASP.NET responds to a request.
Error Occurs when an unhandled exception is thrown.
LogRequest Occurs just before ASP.NET performs any logging for the current request.
MapRequestHandler Occurs when the handler is selected to respond to the request.
PostAcquireRequestState Occurs when the request state (for example, session state) that is associated with the current request has been obtained.
PostAuthenticateRequest Occurs when a security module has established the identity of the user.
PostAuthorizeRequest Occurs when the user for the current request has been authorized.
PostLogRequest Occurs when ASP.NET has completed processing all the event handlers for the LogRequest event.
PostMapRequestHandler Occurs when ASP.NET has mapped the current request to the appropriate event handler.
PostReleaseRequestState Occurs when ASP.NET has completed executing all request event handlers and the request state data has been stored.
PostRequestHandlerExecute Occurs when the ASP.NET event handler (for example, a page or an XML Web service) finishes execution.
PostResolveRequestCache Occurs when ASP.NET bypasses execution of the current event handler and allows a caching module to serve a request from the cache.
PostUpdateRequestCache Occurs when ASP.NET finishes updating caching modules and storing responses that are used to serve subsequent requests from the cache.
PreRequestHandlerExecute Occurs just before ASP.NET starts executing an event handler (for example, a page or an XML Web service).
PreSendRequestContent Occurs just before ASP.NET sends content to the client.
PreSendRequestHeaders Occurs just before ASP.NET sends HTTP headers to the client.
ReleaseRequestState Occurs after ASP.NET finishes executing all request event handlers. This event causes state modules to save the current state data.
ResolveRequestCache Occurs when ASP.NET finishes an authorization event to let the caching modules serve requests from the cache, bypassing execution of the event handler (for example, a page or an XML Web service).
UpdateRequestCache Occurs when ASP.NET finishes executing an event handler in order to let caching modules store responses that will be used to serve subsequent requests from the cache.
Application_OnEnd Event occurs on the end of the Application after all the Session_OnEnd event. Available objects are Application Object and Server Object built-in objects.
Application_OnStart Event occurs on the start of the Application before the first Session_OnStart event. Available objects are Application Object and Server Object built-in objects.

Explicit Interface Implementations

Interface Description
IHttpAsyncHandler.BeginProcessRequest(HttpContext, AsyncCallback, Object) Initiates an asynchronous call to the HTTP event handler.
IHttpAsyncHandler.EndProcessRequest(IAsyncResult) Provides an asynchronous process End method when the process finishes.
IHttpHandler.IsReusable Gets a Boolean value indicating whether another request can use the IHttpHandler object.
IHttpHandler.ProcessRequest(HttpContext) Enables processing of HTTP Web requests by a custom HTTP handler that implements the IHttpHandler interface.

Remarks

  • All items in the collections of Application object is available within the scope of application.

  • An object instance of a component can be assigned to an item of a Contents Collection through the Server.CreateObject method with the Set keyword.

  • And an embedded object can also be assigned to an item of a StaticObjects Collection through the <OBJECT> tag

  • When store an object instance in an Application object, the threading model of objects should be considered because the threading model of objects have a significan impact on the performance and security context of the object.

  • But all built-in objects cannot be assigned to neither a Content Collection nor a StaticObjects Collection.

  • Besides, an array can also be assigned to an item of a Contents Collection in the form of a collection, but the elements of the stored array in the Contents Collection cannot be manipulated as an ordinary array directly because the array is stored as a collection.

  • The methods and properties of ASP application object can be grouped into

    • Setup/Event: Application_OnEnd; Application_OnStart
    • Variable Control: Lock; Unlock
    • Object: StaticObjects
    • Variable:
      • Add/Set: Contents;
      • RemoRemove: Contents.Remove; Contents.RemoveAll

Source/Reference

  • https://docs.microsoft.com/en-us/dotnet/api/system.web.httpapplicationstate?view=netframework-2.0
  • https://docs.microsoft.com/en-us/dotnet/api/system.web.httpapplication?view=netframework-2.0
  • https://support.microsoft.com/en-us/help/312607/info-application-instances-application-events-and-application-state-in
  • https://www.go4expert.com/articles/managing-aspnet-t34148/
  • https://www.go4expert.com/articles/event-handling-aspnet-t34104/
  • https://www.tutorialspoint.com/asp.net/asp.net_managing_state.htm
  • https://www.tutorialspoint.com/asp.net/asp.net_life_cycle.htm
  • https://www.tutorialspoint.com/asp.net/asp.net_quick_guide.htm

©sideway

ID: 190600003 Last Updated: 6/3/2019 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019