How should I configure Session State in my Web application?
You can configure session state by modifying the <sessionstate> element in your web.config file. There are several options you can set in this section.
mode (required)
- Off - Use Off if you do not use session state in your Web application. This can improve the performance of your Web application.
- InProc - This tells ASP.NET to store session state within the ASP.NET worker process(es). Please do NOT use this setting if you want reliable session state. This setting is incompatible with our configuration in the shared hosting environment. Unfortunately, if you use Visual Studio .NET to create your web.config, InProc is the default value and must be changed.
- StateServer - This tells ASP.NET to store session state in an external process. This is the preferred mode for session state in the shared hosting environment and is our system default.
- SQLServer - We do not support SQLServer for storing session state in the shared hosting environment.
cookieless (optional)
- True or False (default) - Specifies whether sessions without cookies should be used. Cookieless sessions can be especially useful if you need to support certain devices, such as cell phones, that do not support cookies.
timeout (optional)
- Used to specify the time in minutes a session can be idle before it is abandoned. The default is 20. We do not recommend increasing this value.
stateConnectionString (optional)
- Used to specify the server name and port for the session State Server. If you are going to specify this value, you should use "tcpip=127.0.0.1:42424". This is the default and you are not required to specify this value.
sqlConnectionString (optional)
- As mentioned above, SQLServer session state mode is not supported so you should never need to specify this attribute
If you do not specify a <sessionState> section in your web.config, your application will use the defaults defined on the server. Below you can see the default configuration on the shared hosting servers:
<sessionState mode= "StateServer"stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="20" />