SqlServices.InstallSessionState Method (String, SessionStateType, String)

 

Installs components for ASP.NET session state on a SQL Server database.

Namespace:   System.Web.Management
Assembly:  System.Web (in System.Web.dll)

public static void InstallSessionState(
	string customDatabase,
	SessionStateType type,
	string connectionString
)

Parameters

customDatabase
Type: System.String

The database on which to install the session-state components.

type
Type: System.Web.Management.SessionStateType

One of the SessionStateType values, specifying the type of session state to install.

connectionString
Type: System.String

The connection string to use. The connection string is only used to establish a connection to the database server. Specifying a database in the connection string has no effect.

Exception Condition
ArgumentException

The type is Custom and the customDatabase value is not supplied, or the type is either Temporary or Persisted and the customDatabase value is not null.

HttpException

Unable to connect to the specified database server.

SqlExecutionException

An exception occurred while processing the SQL statements required for the operation.

The following code example shows how to use the InstallSessionState(String, SessionStateType, String) method of the SqlServices class.

// Install a custom session state database.
SqlServices.InstallSessionState(database,
	SessionStateType.Custom,
	connectionString);

.NET Framework
Available since 2.0
Return to top
Show: