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.