Article ID: 306996 - Last Review: May 16, 2007 - Revision: 3.6 How To Disable ASP Session State in ASP.NET
This article was previously published under Q306996 On This PageSUMMARY This step-by-step article demonstrates how to disable
session state in ASP.NET. When session state is enabled, ASP.NET creates a session for every user who accesses the application, which is used to identify the user across pages within the application. When session state is disabled, user data is not tracked, and you cannot store information in the Session object or use the Session_OnStart or Session_OnEnd events. By disabling session state, you can increase performance if the application or the page does not require session state to enable it. In ASP.NET, if you do not use the Session object to store any data or if any of the Session events (Session_OnStart or Session_OnEnd) is handled, session state is disabled. A new Session.SessionID is created every time a single page is refreshed in one browser session. Disable Session State at the Application LevelThe following steps demonstrate how to disable session state at the Application level, which affects all pages in the application:
Disable Session State at the Page LevelThe following steps demonstrate how to disable session state at the Page level, which affects only the specific pages that enable these changes:
TroubleshootingIf you try to set or retrieve information when session state is disabled, you receive the following error message:
Session state can only be used when enableSessionState is set to true, either
in a configuration file or in the Page directive REFERENCES For more information about session state, refer to the
following topics in the .NET Framework Software Development Kit (SDK)
documentation:
ASP.NET Session State http://msdn2.microsoft.com/en-us/library/ms972429.aspx (http://msdn2.microsoft.com/en-us/library/ms972429.aspx) <sessionState> Section http://msdn2.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx)
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|





















Back to the top