[ASP. NET] Status Management

Source: Internet
Author: User

HTTP is a stateless protocol, so the status cannot be shared among different requests. However, it is useful to maintain the status between different requests. For example, the implementation of shopping cart on a shopping website depends on this state.

ApplicationProgramStatus Management

Presumably many peopleCodeSegment is very familiar:

Application. Lock (); application ["myglobalcounter"] = (INT) application ["myglobalcounter"] + 1; application. Unlock ();
 
Application is an instance of the httpapplicationstate class.
 
It exists throughout the lifecycle of a Web application.
 
 
 
Session Status
 
When a browser requests an application for the first time, the server starts a session,
 
Future requests will share these session statuses.
 
The first response of these requests will return a sessionid,
 
In the future, this sessionid will be used as the token to access the session status.
 
Sessionid can be transmitted in two ways:
 
1) Cookie
2) No cookie is used, but is inserted into the URL and delivered to the server.
 
ASP. NET supports three session Status modes: inproc, StateServer, and sqlserver.
  Advantages Disadvantages
Inproc 1st segment is directly read from aspnet_wp.exe, so the performance is the best.

1)aspnet_wp.exe may be recycled for many reasons (for example, the web. config, bin directory or memory usage in the virtual directory has reached the maximum. Therefore, it is quite unstable.
2) It is not applicable to Web garden deployment, but not to Web farm deployment.
StateServer 1) Session variables in this mode are stored in a Windows service independent of IIS, so they are not affected by the collection mechanism of IIS worker processes.
2) It is applicable to the Web garden and web farm deployment modes.
1) there is a problem of Cross-process or cross-machine (because this Windows service can be deployed on another server), and the performance is low.
Sqlserver In addition to StateServer (1) and 2), StateServer has the following advantages:
3) more persistent
1) lower performance, because you need to read SQL Server, reverse sequence, and so on.

 

reference: http://msdn.microsoft.com/en-us/library/87069683 (vs.71). aspx

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.