HOW TO: Configure SQL Server to Store ASP.NET Session State (317604)
The information in this article applies to:
- Microsoft ASP.NET (included with the .NET Framework 1.1)
- Microsoft ASP.NET (included with the .NET Framework) 1.0
- Microsoft SQL Server 2000 (all editions)
- Microsoft SQL Server 7.0
- Microsoft SQL Server 2000 64 bit (all editions)
This article was previously published under Q317604 SUMMARY This step-by-step article demonstrates how to configure
Microsoft SQL Server for ASP.NET SQL Server mode session state
management.
back to the top
Requirements The following list outlines the recommended hardware, software,
network infrastructure, and service packs that you need:
- Microsoft Windows 2000 Professional, Microsoft Windows 2000
Server, Microsoft Windows 2000 Advanced Server, or Microsoft Windows
XP
- Microsoft .NET Framework
- Microsoft Internet Information Services (IIS)
- Microsoft SQL Server
back to the top
Configure SQL Server for ASP.NET SQL Server Session State The following steps describe how to run the InstallSqlState.sql
and the UninstallSqlState.sql script files to configure SQL Server mode session
state management.
- In SQL Query Analyzer, on the File menu, click Open.
- In the Open Query File dialog box, browse to the InstallSqlState.sql script file, and
then click Open. By default, InstallSqlState.sql is located in one of the
following folders:
system drive\WINNT\Microsoft.NET\Framework\version\
system drive\Windows\Microsoft.NET\Framework\version\ - After InstallSqlState.sql opens in SQL Query Analyzer,
click Execute on the Query menu to run the script.
- Before you run the UninstallSqlState.sql script file to
uninstall SQL Server mode session state management configuration, you must stop
the w3svc process. To do this, follow these steps:
- On the Windows Start menu, click Run, type cmd, and then click OK to open a command prompt.
- At the command prompt, type net stop
w3svc. You receive confirmation that the w3svc process is
stopped.
- In SQL Query Analyzer, on the File menu, click Open.
- In the Open Query File dialog box, browse to the UninstallSqlState.sql script file, and
then click Open. By default, UninstallSqlState.sql is located in one of the
following folders:
system drive\WINNT\Microsoft.NET\Framework\version\
system drive\Windows\Microsoft.NET\Framework\version\ - After UninstallSqlState.sql opens in SQL Query Analyzer,
click Execute on the Query menu to run the script.
- After you uninstall SQL Server mode session state
management configuration, you must restart the w3svc service. To restart the
w3svc process, type net start w3svc at a command
prompt.
back to the top
Modify the Web.config File of Your Application To implement ASP.NET SQL Server mode session state management,
you must modify the <sessionState> element of your application's Web.config file as follows:
- Set the mode attribute of the <sessionState> element to SQLServer to indicate that session state is stored in SQL
Server.
- Set the sqlConnectionString attribute to specify the connection string for SQL Server. For
example:
sqlConnectionString="data source=MySQLServer;user id=<username>;password=<strongpassword>"
Note The
user, <user name>, must have permissions to perform this operation on the
database.
The modified <sessionState> element should appear as follows:
<sessionState
mode="SQLServer"
sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strongpassword>"
cookieless="false"
timeout="20"
/>
Note Ensure that you use the correct case when you specify the <sessionState> element and the associated attribute values. This code is case
sensitive.
back to the top
Troubleshooting
back to the top
REFERENCESFor additional information, click the article numbers below
to view the articles in the Microsoft Knowledge Base: 307598 INFO: ASP.NET State Management Overview
236166 Using NET STOP and NET START Commands to Force IIS Services to Re-Read the Registry
For more information about ASP.NET session state
management, refer to the following Microsoft Web sites:
back to the top
Modification Type: | Major | Last Reviewed: | 6/12/2006 |
---|
Keywords: | kbConfig kbHOWTOmaster kbState kbWebForms KB317604 kbAudDeveloper |
---|
|