Asp. NET to save the session to the database

Source: Internet
Author: User

Because the access mechanism of the session in ASP is the same as ASP, it is kept in progress,

Once the process crashes, all session information will be lost, so I have taken the session information to SQL Server, although there are other

Several ways (not described in this article), to save the session to SQL Server, you need the following steps:

1. First to create a database to hold session data, in the form of a command line with Aspnet_regsql.exe to complete, the specific command is

C:\windows\microsoft.net\framework\v2.0.50727>aspnet_regsql.exe-ssadd-sstype C
-D sd-e

This command is the Windows authentication method, the SD database is added to save the session data.

2. You need to modify the sessionstate node in the ASP. Net. config file, which is located at <system.web>

<sessionstate mode= "SQL Server" allowcustomsqldatabase= "true"
Sqlconnectionstring= "server=.; Uid=sa;password=;initial CATALOG=SD "
Cookieless= "false"
Timeout= ">"
</sessionState>

In this way, the session data is no longer dependent on the IIS process but is saved to the database. You can open the SD database with two tables, aspstatetempsessions, Aspstatetempapplications, respectively.

Asp. NET to save the session to the database

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.