ASP. NET Method for saving Session to database

Source: Internet
Author: User

The following steps are required to save a Session to SQL Server:

1. First, you must create a database that saves sessiondata and use aspnet_regsql.exe as a command. The specific command is

C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727> aspnet_regsql.exe-ssadd-sstype c
-D sd-E

This command adds an sd database to save session data in windows Authentication mode.

2. Modify the SessionState node in the ASP. NET web. config file, which is located under <system. web>.
Copy codeThe Code is as follows:
<SessionState mode = "SQLServer" allowCustomSqlDatabase = "true"
SqlConnectionString = "server =.; uid = sa; password =; initial catalog = sd"
Cookieless = "false"
Timeout = "20">
</SessionState>

In this way, Session data is stored in the database instead of being dependent on the IIS process. You can open the sd database with two tables: ASPStateTempSessions and ASPStateTempApplications.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.