The easiest way to asp.net|session is to not use the default method
InProc (default, session state in process): Sessions are stored in the IIS process (Web server memory). If you are using Windows Server or Windows Xp,iis Use the Aspnet_wp.exe process, use w3wp.exe if you are using Windows 2003 Server,iis.
InProc has the best performance. But in-process sessions can easily lose session information. If you restart the application, all session information is lost. Many of the reasons cause the ASP.net application to restart.
Modified the Web.config or Global.asax file, or changed the date of the file modification.
Modify the files in \ bin or \App_Code directory.
Antivirus software modifies the above files and so on
You can consider the following two ways
StateServer (out-of-process session state): Sessions are stored in separate Windows service process Aspnet_state.exe
If you want to enable session status in StateServer, you first enable ASP.net state services (asp.net status service) in Control Panel-Administrative Tools-services. and set this service to Automatic (auto start)
After you start the ASP.net state service, you need to configure the ASP.net application to use it.
We need to add the following code to the system.web node in the Web.config file
<sessionstate mode= "StateServer" statenetworktimeout= "20"
stateconnectionstring= "tcpip=127.0.0.1:42424"/>
First, the Mode property is set to StateServer. The stateConnectionString property is then used to specify the location of the ASP.net state server side. The connection location is created at 127.0.0.1, Port 42424. Finally, the stateNetworkTimeout property is used to specify the number of seconds the connection times out.
It is important to note that at this point the object must be annotated as serializable (a class that needs to be serialized using the serializable attribute) to be stored in the service. Microsoft recommends that all developers use out-of-process session state during development to avoid site errors if the project switches to a different out-of-process provider or to SQL Server.
or use
Sqlserver:session is stored in a table in the SQL Server database and can be configured with aspnet_regsql.exe (SQL Server servers)
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