Wednesday, 28 December 2011

Application State:

Application State: Application state is a global storage mechanism accessible from all pages in the Web application and is useful for storing information that needs to be maintained between server round-trips and between pages.Application state is stored in the memory of the windows process which is processing user requests on the web server.

In ASP.Net, application state is an instance of HttpApplicationState class and it exposes key-value pairs to store information. Its instance is automatically created when a first request is made to web application by any user and same state object is being shared across all subsequent users. It is useful for storing information that needs to be maintained between server round trips and between requests for pages.

Once you add your application-specific information to application state, the server manages it. Following is an example of using application state in an application.
//Stroing information in application state
lock (this)
{
Application["NickName"] = "Merithub";
}
//Retrieving value from application state
lock (this)
{
string str = Application["NickName"].ToString();
}

No comments:

Post a Comment