This code is the way to set the session's storage in Web.config.
< sessionstate mode= "off| inproc| stateserver| SQL Server "
Cookieless= "True|false"
timeout= "Number of minutes"
Stateconnectionstring= "Tcpip=server:port"
sqlconnectionstring= "SQL connection string"
statenetworktimeout= "Number of seconds"
/>
Code Detailed:
Prerequisite attributes:
Mode setting where the session information is stored
Off is set to do not use the session feature
InProc is set to store sessions in-process, which is how the ASP is stored, which is the default value.
StateServer is set to store sessions in a separate state service.
SQL Server settings store sessions in SQL Servers.
The optional properties are:
Cookieless set up where the client's session information is stored
Ture Use cookieless mode
False uses cookie mode, which is the default value.
Timeout the server automatically discards session information after the number of minutes after the setting. Default is 20 minutes
stateConnectionString sets the server name and port number used when session information is stored in the status service, for example: "tcpip=127.0.0.1:42424". When Mode's
The value is StateServer is, this attribute is required.
sqlConnectionString sets the connection string when connecting to SQL Server. For example, "Data source=localhost;integrated security=sspi;initial
Catalog=northwind ". This property is required when the value of mode is SQL Server.
stateNetworkTimeout sets the server that disconnects the Web server from storing state information when the session state is stored in the StateServer mode, after how many seconds are idle.
TCP/IP connection. The default value is 10 seconds.
Asp. Storage of client session state in net
In our introduction to the session model above, you can find that the session state should be stored in two places, respectively, the client and server side. The client is only responsible for saving the network
The SessionID of the station, while the other session information is saved on the server side. In ASP, the client's SessionID is actually stored as a cookie. If the user is in the browser's
If you choose to disable cookies in the settings, he will not be able to enjoy the convenience of the session, or even make access to some Web sites. In order to solve the above problem, the client in asp.net
The session information storage way is divided into: cookie and cookieless two kinds.
Asp. NET, the session information is stored by default in the client or by using cookies. If we want to store session information in a cookieless way on the client side
The law is as follows:
Locate the root directory of the current Web application, open the Web.config file, and locate the following paragraph:
< sessionstate
Mode= "InProc"
Stateconnectionstring= "tcpip=127.0.0.1:42424"
sqlconnectionstring= "Data source=127.0.0.1; Trusted_connection=yes "
Cookieless= "false"
Timeout= "20"
/>
the life cycle of the session variable.
Technical points:
When you configure the lifecycle of the session variable in the Web.config file in the <sessionState></sessionState> node, you can set the following parameters when you configure the life cycle.
Mode: This parameter is used to set the storage session state. The status includes off, Inproc, StateServer, and SQL Server. Off indicates that session state is disabled; InProc indicates that the worker process itself stores session state; StateServer represents that the session information is stored in a separate asp.net state service; SQL Server indicates that the session information will be stored in SQL Server. stateConnectionString: This parameter is used to set the server name that the ASP.net application stores remotely with, default to local. Cookieless: When this parameter value is set to True, indicates that the client is not identified using a cookie session, and when set to False, the start cookie session state is indicated. sqlConnectionString: This parameter is used to set up a SQL Server database connection. Timeout: This parameter is used to set session time, exceeding this parameter period, automatic middle session, default is 20.
The method for configuring Web.config files is as follows:
Add the following code to the <system.web></system.web> node of the Web.config file to set the session life cycle to 10 minutes. Code: <sessionstate mode= "InProc" timeout= "ten" ></sessionState>