How to configure session state mode by default in ASP.NET

Software developer can configure session state mode by default if he set it to “InProc”. In this case the other two settings have no effect. In this mode the information will be stored in the same process as the ASP.NET worker threads, i.e. software developer will expect best performance, but the least durability. If he restart web server, the state information will be lost.

InProc option makes sense for most small web sites.    In a web farm scenario the option will not work. To allow session state to be shared between servers software developer must use the out-of-process or SQL server state service.

 

<?xml version=”1.0” encoding=”utf-8” ?>
<configuration>
     <system.web>
     <!— other settings are omitted. —>
     <sessionState
        cookieless=”AutoDetect” cookieName=”ASP.NET_SessionID”
        regenerateExpiredSessionID=”false”
        timeout=”20”
        mode=”InProc”
        stateConnectionString=”tcpip=127.0.0.1:42424”
        stateNetworkTimeout=”10”
        sqlConnectionString=”data source=127.0.0.1;Integrated Security=SSPI”
        sqlCommandTimeout=”30” allowCustomSqlDatabase=”false”
        customProvider=””
     />
     </system.web>
</configuration>