Session storage method.

Source: Internet
Author: User

You can set the session Status Saving Method in webconfig.

The default value is inproc, Which is saved in the process. The advantage of this storage method is that the reading speed is fast. of course, because the session is stored in the process, the session may be lost at a certain moment because the process is closed.

 

You can select StateServer, Which is saved to the status service on the server. You can view it in the management tools> service.

If it is set to StateServer, first set the class in the session to a serializable class. If it is set to StateServer, an error is returned.

 

// Serializable class
[Serializable ()]

Public class etsuser
{

# Region variable
Private int userid;

Private string email;

Private int sex;

Private system. datetime birthday;

Private string passwordquestion;

Private string passwordanswer;

[Serializable ()] or [serializable] above the Declaration class

 

Then set the status service to enable. In this way, the session will be saved in the status service. If the session does not expire and the server does not restart, the session will be lost less than inproc.


In iis7, you can also change the session storage mode. The iis7 setting will automatically change the config file published in the web project in IIS.



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.