1)
InProc--this way the session state is stored in the ASP. NET run process, in the location of the cache (cache) of ASP. 2)
StateServer--this way the session state is saved in the Wiindows service process with ASP. The service is disabled by default and requires manual startup. 3)
SQL Server--this way the session state is saved to a database managed by SQL Server. Specifically, it can be divided into three ways, which are saved in the staging database, the ASPState database and the custom database. 4)
Custom Provider--This approach requires the developer to develop the provider of the session state themselves, and access to the session state is entirely determined by the provider, which can be saved in other SQL databases, or XML files, or even text files. The purpose of this article is to explain how to configure the use of SQL Server to save session state. The entire configuration process is divided into two parts: the first part, on the server where the ASP. NET program is running, configure the database server that is used. The second section modifies how session state is saved in the configuration file of the ASP.
Configure the database server that you are using: 1) Run the Aspnet_regsql.exe program, which is located in directory c:\windows\microsoft.net\framework\<asp. NET version number > below. First double-click to run the program and configure SQL Server for ASP. Select next to select as shown in the figure, and then next to populate the database server information associated with ASP. Note that the database selected here can be changed in the future ASP. After the completion of the selection of "next" after the two interface, but in those two interfaces only need "next", there is no selectable information, so this is not listed here. 2) Configure the database library used for session state. As mentioned earlier, there are three ways to save a session using a database, the staging database (which will lose data after the SQL Server restarts), the ASPState database, and the custom database. Note-ssadd,-E,-sstype directives.
-ssaddThe function of the command is to add the session database, which is added to the staging database by default
- eThe function of the directive is to use Windows authentication because I am demonstrating that SQL Server is on this computer, so use this directive to connect, and separate-ssadd is not operational.
-sstypeThe function of the directive is to specify which database to use for session state. The subsequent parameters are T, P ' and C, respectively, the staging database, the ASPState database library, and the custom database.
- Dfunction is to specify the name of the database when specifying a custom database, and to make parameters with the database name.
instructions for saving session state using the staging database: There are two more tables in the staging database for saving session state information.
instructions for saving session state using the ASPState database: After execution, a new database aspstate appears in the database. The table that comes with it is consistent with the previous one in the staging database.
instructions for saving session state using a custom database Testcustom database: In addition to having the table above, there are a series of automatically added stored procedures, which are not custom database specific. Regardless of which database you use, there are stored procedures, but when you change from one database to another, the tables stay, but the stored procedures are all transferred to the newly used database. To cancel using the above settings, only-SSREMOVE-E instructions are required. These can only be used to create the session database in the native database, but the normal operation should not be done directly on the database server, it is likely that the server does not have ASP. So we need to configure the remote connection from the deployment server of the ASP. The following will demonstrate this instance of connecting to a team member's remote computer through my computer. To illustrate, to run aspnet_regsql.exe in Cmd, to make a remote connection, you need to use the-s-u-P directive, specifying the database server name/address, the account number and password used for the connection. It must also be noted that to configure the session database in SQL Server, you must have
Create tables, create databases, create stored procedures, and RSExecRole role permissions for msdb。 Otherwise the configuration process must be error-prone.
The above configuration instructions on the 119.120.74.150 machine, use the account password is silin to establish a connection, and then create a custom database Testcustom to save the session state. This is the configuration for ASP. NET using SQL Server. Next is the modification of the configuration file.
to modify the configuration file for an ASP.: Find the <sessionState> section in the ASP. NET configuration file, it is likely that there is no such segment because there is a default setting, where this section is assumed to be re-written. <sessionstate mode= "SQL Server" sqlconnectionstring= "required connection string"/> only need such a simple setting. Of course there are other settings, but to play a role, at least these two property settings will be OK. After the above settings are completed, the session data that is accessed in the program is automatically saved to the database and the entire encoding process is not changed. Asp. NET of this provider mechanism, indeed the implementation of the code is separated from the way data is saved. Note, however, that when you save a session state to a piece of media other than the ASP. NET running process, it must be serialized and deserialized, so be aware that the type saved in the session state can be serialized.