Article ID: 307598 - Last Review: May 16, 2007 - Revision: 4.7 INFO: ASP.NET State Management OverviewThis article was previously published under Q307598 On This PageSUMMARY This article provides an introduction to the ASP.NET state
management features. For additional ASP.NET overviews, refer to the following Microsoft Knowledge Base article: 305140
(http://support.microsoft.com/kb/305140/
)
INFO: ASP.NET Roadmap
MORE INFORMATION HTTP is a stateless protocol. Each request is serviced as
it comes; after the request is processed, all of the data is discarded. No
state is maintained across requests even from the same client. However, it is very useful to maintain state across requests for certain solutions. ASP.NET enables you to maintain both application state and session state through use of application and session variables respectively. This article addresses the following state management topics: Application StateApplication state variables are, in effect, global variables for each ASP.NET application. You can share values of these variables throughout that application. These variables are usually set in the Application_OnStart event and then accessed and modified in individual ASP.NET pages.The lifetime of application variables spans through the lifetime of the ASP.NET application until the application is unloaded. For more information about application state, refer to the following topic in the .NET Framework Software Development Kit (SDK) documentation:
Application State http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconapplicationstate.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconapplicationstate.asp) Session StateYou can store values that need to be persisted for the duration of a user's session in session variables. These variables are unique to each user session and can be accessed in any ASP.NET page within an application. You can set and access session information from within an ASP.NET application. For example:Microsoft Visual Basic .NET Session variables are automatically discarded after they are not used for the time-out setting that is specified in the Web.config file. On each request, the time out is reset. The variables are lost when the session is explicitly abandoned in the code. When a session is initiated on first request, the server issues a unique session ID to the user. To persist the session ID, store it in an in-memory cookie (which is the default), or embed it within the request URL after the application name. To switch between cookie and cookieless session state, set the value of the cookieless parameter in the Web.config file to true or false. In cookieless mode, the server automatically inserts the session ID in the relative URLs only. An absolute URL is not modified, even if it points to the same ASP.NET application, which can cause the loss of session variables. ASP.NET supports three modes of session state:
For more information about session state, refer to the following topic in the .NET Framework SDK documentation:
Session State http://msdn2.microsoft.com/en-us/library/87069683(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/87069683(vs.71).aspx) Configuring Session StateYou can configure session state in the <sessionState> configuration section of the Web.config file. The <sessionState> configuration section appears similar to the following:
<sessionState> Section For additional information, click the
following article number to view the article in the Microsoft Knowledge Base: http://msdn2.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx) 317604
(http://support.microsoft.com/kb/317604/
)
HOW TO: Configure SQL Server to
Store ASP.NET Session State
REFERENCES For more general information about ASP.NET, refer to the
following MSDN newsgroup: microsoft.public.dotnet.framework.aspnet
(http://msdn.microsoft.com/newsgroups/default.aspx?query=microsoft.public.dotnet.framework.aspnet&dg=&cat=en-us-msdn&lang=en&cr=US&pt=&catlist=774F24A2-F71F-425F-AC2B-DC48AB0DA5C9&dglist=&ptlist=&exp=&sloc=en-us)
| Article Translations
|
Back to the top
