All of the configuration is provided by the
<sessionState> element in the web.config
file; all you have to do is alter the appropriate attributes.
There are several ways to store session information; these are described next.To disable
Session state, add this to web.config:
<configuration>
<system.web>
<sessionState mode="Off"/>
</system.web>
</configuration>
To enable local storage of Session state, add this to web.config:
<configuration>
<system.web>
<sessionState mode="InProc"
cookieless="true"
timeout="10" />
</system.web>
</configuration>
The InProc setting sets it so that the information is stored locally (the default).
Cookieless can be set to true or false and tells ASP.NET whether to use cookies
when storing session information. Timeout sets the time in minutes that sessions will
expire if they remain unused.
To enable storage of Sessions on a state server add this to web.config:
<configuration>
<system.web>
<sessionState mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424" />
</system.web>
</configuration>
This tells ASP.NET to use a state server at the specified address (stateConnectionString).
The state server is found at %SYSTEMROOT%\Microsoft.NET\Framework\version\
aspnet_state.exe.This server then listens on port 42424 over TCP/IP; you can use
this port to store your session information.
To enable storage of Sessions on a SQL Server, add this to web.config:
<configuration>
<system.web>
<sessionState mode="SQLServer"
sqlConnectionString="data source=localhost;user id=sa;
➥password=securepassword;" />
</system.web>
</configuration>
This method tells ASP.NET to use SQL Server to store the information.To set up a
SQL Server to store session information, you must run the InstallSqlState.sql file located
in %SYSTEMROOT%\Microsoft.NET\Framework\version\ on the SQL Server (there is an
UninstallSqlState.sql file to uninstall it as well).
No comments:
Post a Comment