How to: Configure SQL Server To Store ASP.NET Session State

xiaoxiao2021-03-06  43

How to: Configure SQL Server To Store ASP.NET Session State

Suitable

This Article Was Previously Published Under Q317604

In this task

Summary

Requirements Configure SQL Server for ASP.NET SQL Server Session State Modify The Web.Config File of Your Application Troubleshooting References

Summarythis Step-by-Step Article Demonstrates How To Configure Microsoft SQL Server for ASP.NET SQL Server Mode Session State Management.

Back to the top

RequirementSthe 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 StateThe 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 Applicationto Implement ASP.NET SQL Server Mode Session State Management, You Must Modify THE

Element of Your Application's Web.Config File As Follows:

Set the mode attribute of the 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 = ; password = "

Note The User, , Must Have Permissions to Perform this Operation on The Database.the Modified Element SHOULD APPEAR AS FOLLOWS:

Mode = "SQLServer"

SqlConnectionstring = "data source = 127.0.0.1; user ID = ; password = " cookieless = "false"

TIMEOUT = "20"

/>

Note EnSure That You Use the Correct Case When You Specify The Element and the associated attribute values. This code is case sensitive.

Back to the top

Troubleshooting

IF you do not stop the w3svc process before you run the uninstallsqlstate.sql script file, you receive the folowing error message:

Cannot Drop The Database 'AspState' Because IT IS Currently in Use

If entries in the ASPStateTempSessions table are not removed after the related sessions expire, make sure that the SQL Server agent is running. You can implement this functionality through stored procedures that are scheduled through jobs in SQL Server. The SQL Server agent manages these jobs. When you use the default InstallSqlState.sql and UninstallSqlState.sql script files to configure ASP.NET SQL Server mode session state management, note that these files add the ASPStateTempSessions and the ASPStateTempApplications tables to the tempdb database in SQL Server by default. Furthermore, if you restart SQL Server, you lose the session state data that was stored in the ASPStateTempSessions and the ASPStateTempApplications tables.For additional information about how to run alternative scripts to configure persistent SQL Server session state management so that the session data is not lost when you restart The Server, Click The Article Number Below To View The Article in The Microsoft Know LEDGE BASE:

转载请注明原文地址:https://www.9cbs.com/read-118521.html

New Post(0)