ASP. NET: Session timeout and loss issues

Source: Internet
Author: User
Recently, I encountered a Session Timeout problem. In fact, at the beginning, I thought it was very simple. Program Write
Protected void page_load (Object sender, eventargs E)
{
If (! Page. ispostback)
{
Session. Timeout = 120;
}
}
In fact, I don't know whether it works or not. Baidu seems to need to set webconfig, but it doesn't seem to work, so I found another method.

1
This solves the timeout problem, however, this is extremely insecure. vs.net's default setting
is equivalent to handing over the session to the IIS process management, IIS instability will cause frequent session loss
2 sessionstate mode = 'stateserver 'is the service process management mode for creating an independent session,
This is not affected by the instability of IIS processes, and cannot easily lead to session loss.
This allows session sharing of multiple Asp.net sites.
then I considered this method and reset webconfig
stateconnectionstring = "TCPIP = 127.0.0.1: 42424 "
cookieless =" false "
timeout =" 60 "/>
however, to start a service, choose management tools> service> Asp. net state service can be started.
there is no problem on the local machine, but the problem occurs when it is uploaded to the server. The IP address and port are incorrect and I don't know how to modify it.
In fact, this method is acceptable, but we only have virtual hosts and no servers of our own, so I have no way to start this service on the server.
you can set it to replace the IP address of the server but modify the port:

modify the service port of aspnet_state:
edit the port value in the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ aspnet_state \ Parameters registry.
but I don't know how to perform the operation, so I have to put it down for the moment.
3. You can also save the session to Data ,. Even if the service is restarted, the session will not be lost. The stability of the website is still important. Microsoft's default settings are the worst.
This method has not been studied, because the company has always asked me to use access.
these three attributes are described in detail.

Inproc Session value in the ASP. NET auxiliary process (in Microsoft Windows Server 2003Aspnet_wp.exeOrW3wp.exe. This is the default option.
StateServer Session values are serialized and stored in separate processes (Aspnet_state.exe. This process can also run on other computers.
Sqlserver Session values are serialized and stored in Microsoft SQL Server tables. SQL Server instances can be run locally or remotely.

However, we still need to modify it, so we had to adopt the first method. In fact, this is because of hardware reasons. Boss cannot buy a server because I just bought one sentence, I had to find another path ......

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.