asp.net.ph

Skip Navigation LinksHome > ASP.NET Applications > ASP.NET Optimization > Developing High-Performance ASP.NET Applications

Developing High-Performance ASP.NET Applications

ASP.NET Web Applications   ASP.NET Optimization


State Management

The following guidelines suggest ways on how to manage state more efficiently.

Disable session state when you are not using it

Not all applications or pages require per-user session state, and you should disable it for any that do not.

To disable session state for a page, set the EnableSessionState attribute in the @ Page directive to false, as in the folowing example.

<%@ Page EnableSessionState = "false" %>

NOTE: If a page requires access to session variables but will not create or modify them, set EnableSessionState attribute in the @ Page directive to ReadOnly.

Session state may also be disabled for web service methods. For more information, see Web Services Overview.

To disable session state for an application, set the Mode attribute to "off" in the sessionState configuration section in the application’s Web.config file, as in the following example.

<sessionState mode = "off" />

Choose your session state provider carefully

ASP.NET provides three distinct ways to store session data for your application: in-process session state, out-of-process session state as a Windows Service, and out-of-process session state in a SQL Server™ database. Each has it advantages, but in-process session state is by far the fastest solution.

If you are only storing small amounts of volatile data in session state, it is recommended that you use the in-process provider. The out-of-process solutions are primarily useful if you scale your application across multiple processors or multiple computers or where data cannot be lost if a server or a process is restarted.

More ...
Back to top


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note