Session State of ASP. NET

Source: Internet
Author: User
Tags net xml

For this reason, ASP users have to manually synchronize session information to the external database with session ID as the primary key to alleviate similar problems.

In ASP. NET, because these problems are taken into account during design, these restrictions can be avoided: 1. supports off-Process status management, and manages session status through the independent status management service or SQL Server Status Server 2. you can maintain the status without using cookies. You can avoid using cookies by automatically adding session IDs to URLs. session information is used synchronously when Server Load balancer is supported by independent status management service or SQL Server Status Server. Session StateModule mentioned in the previous section. in the InitModuleFromConfig function, four different State Manager implementations are selected based on the mode attribute of the Session State mark.

The following is the program code:

 
 
  1. <system.web> 
  2. <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" 
    stateNetworkTimeout="10" sqlConnectionString="data source=127.0.0.1;
  3. Integrated Security=SSPI" cookieless="false" timeout="20" /> 
  4. </system.web> 

In Off mode, Session management is prohibited. ASP. NET also allows the following program code to support Session status on the fine-grained Management page using the Enable Session State attribute on the page:

 
 
  1. <%@ Page EnableSessionState=" True|False|ReadOnly" %> 

The InProc mode is compatible with the previous ASP policy.. NET implements memory-based session STATE management in the same process space, which is the fastest but subject to the same limits as ASP. NET independent installation of ASP. NET State Service aspnet_state.exe), responds to the session Status Service with the IP address and port specified by stateConnectionString. In SQLServer mode, the SQL Server specified by sqlConnectionString is used as the memory temporary table to InstallSqlState. SQL database creation, use tempdb Memory Database) or independent tables with InstallPersistSqlState. SQL monitoring, using an independent ASPState Library) to maintain the session status.

Performance Tuning and Optimizing ASP. NET Appliation: Reference Table 4-1: Normalized TTLBTime to Last Byte) bySession State Mode in Milliseconds per 100 Requests)

Concurrent browsers mode = off mode = inproc mode = state server mode = SQLSERVER 1 7.81 4.54 8.27 8.47 5 28.28 20.25 27.25 29.29 10 89.38 46.08 77.29 85.11 Table 4-2: average Requests per Second bySession State Mode concurrent browsers mode = off mode = inproc mode = state server mode = SQLSERVER 1 18.86 24.17 18.31 18.11 5 21.66 25.74 21.54 10 21.34 17.23 23.8 18.11 17.6, whether it is from TTLB or the average number of requests per second The performance of the off-Process status manager is acceptable. Of course, you also need to optimize the status management when writing code. However, to use the out-of-Process status manager, the objects stored in the session are limited by the need to increase support for binary serialization.

From the perspective of usage, the status manager is actually established and managed by the HttpSessionModule mentioned in the previous section and accessed through the Http Session State interface. The structure is as follows: underpinnings of theSession State Implementation in ASP on MSDN. NET explains in detail the principles and usage of several different State managers.

  1. Data source controls in ASP. NET
  2. Introduction to the use of XML Web Services in ASP. NET
  3. Web. config file of ASP. NET application
  4. Overview ASP. net xml Web Services
  5. Implement HTTP requests in ASP. NET

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.