Wednesday, November 25, 2009

Turn off Session State when not required

Asp.net Session state is ON by default. Memory is lost even if we don't use this session state.
To improve the performance we need to turn off the session state when we are not in use.

Below are the different ways to turn off the session state.

  1. If you don't want the session for your entire application then,turn off the session state in web.config file.<system.web>
        <sessionState mode="Off"></sessionState>


  2. If session is not required for few pages , then turn off the session state in page level.
         <system.web>

           <pages enableSessionState="false">  

  3. If you want to enable the session state for particular page

    <%@ Page ... EnableSessionState="true" %>




0 Comments:

blogger templates | Make Money Online