Session State Configuration in ASP.NET 4.0

Session state management is one of ASP.NET's Features. It allows to store any type of data in memory on the server. The information is protected, because it is never transmitted to the client, and it's uniquely bound to a specific session. Every client that accesses the application has a different session and a distinct collection of information. Session state is ideal for storing information such as the items in the current user's shopping basket when the user browses from one page to another.

We can configure session state through the web.config file in Asp.NET. The configuration file allows you to set advanced options such as the timeout and the session state mode.

The code below shows the most important options that we can set for the <sessionState> element.

 <?xml version="1.0" ?>

<configuration>

<system.web>

<sessionState cookieless="UseCookies"cookieName="ASP.NET_SessionId"

regenerateExpiredSessionId="false" timeout="20" mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424" stateNetworkTimeout="10"

sqlConnectionString="datasource=127.0.0.1;Integrated Security=SSPI"

sqlCommandTimeout="30"allowCustomSqlDatabase="false"

  customProvider="" compressionEnabled="false"/>

</system.web>

</configuration>


Thank You...

Ebook Download
View all
Learn
View all