Skip Headers
Oracle® Providers for ASP.NET Developer's Guide
11g Release 2 (11.2.0.3) for Microsoft Windows

Part Number E18737-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

OracleSessionStateStore Class

The OracleSessionStateStore class allows ASP.NET applications to store session information in an Oracle database.

Class Inheritance

System.Object

  System.Configuration.Provider.ProviderBase

    System.Web.SessionState.SessionStateStoreProviderBase

      Oracle.Web.SessionState

Declaration

// C#
public class OracleSessionStateStore : SessionStateStoreProviderBase

Thread Safety

All public static methods are thread-safe, although instance members are not guaranteed to be thread-safe.

Remarks

This class allows ASP.NET applications to store and manage session state information in an Oracle database.Note that the session information that this provider manages is application session information, not database session information.

Expired session data is periodically deleted from the database.

Example

The following is a web.config example for an ASP.NET application that uses OracleSessionStateStore as the default provider with customized settings and an application-specific connection string:

<?xml version="1.0"?>
<configuration xmlns=
  "http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <connectionStrings>
    <add name="my_sessionstate_app_con_string" connectionString=
      "User Id=scott;Password=tiger;Data Source=Oracle"/>
  </connectionStrings>
  <system.web>
    <!-- Enable and customize OracleSessionStateProvider -->
    <sessionState mode="Custom" customProvider="MyOracleSessionStateStore">
      <providers>
        <add name="MyOracleSessionStateStore" 
             type="Oracle.Web.SessionState.OracleSessionStateStore, 
             Oracle.Web, Version=2.112.2.0, Culture=neutral, 
             PublicKeyToken=89b483f429c47342" 
             connectionStringName="my_sessionstate_app_con_string"/>
      </providers>
    </sessionState>
  </system.web>
</configuration>

Requirements

Namespace: Oracle.Web.SessionState

Assembly: Oracle.Web.dll

Oracle Providers for ASP.NET Version: Oracle Providers for ASP.NET 2.0 and Oracle Providers for ASP.NET 4


OracleSessionStateStore Members

OracleSessionStateStore members are listed in the following tables.

OracleSessionStateStore Constructors

The OracleSessionStateStore constructor is listed in Table 5-1.

Table 5-1 OracleSessionStateStore Constructor

Constructor Description

OracleSessionStateStore Constructors

Instantiates a new instance of the OracleSessionStateStore class


OracleSessionStateStore Public Properties

OracleSessionStateStore public properties are listed in Table 5-2.

Table 5-2 OracleSessionStateStore Public Properties

Public Properties Description

CommandTimeout

Gets the number of seconds that the command is allowed to execute before it is terminated with an exception

Description

Inherited from System.Configuration.Provider.Providerbase

Name

Inherited from System.Configuration.Provider.Providerbase


OracleSessionStateStore Public Methods

The OracleSessionStateStore public methods are listed in Table 5-3.

Table 5-3 OracleSessionStateStore Public Methods

Public Methods Description

CreateNewStoreData

Creates a new SessionStateStoreData object for the current request

CreateUninitializedItem

Adds a new session state item to the database

Dispose

Releases all the resources for this instance

EndRequest

Allows the OracleSessionStateStore object to perform any cleanup that may be required for the current request

GetItem

Returns a read-only session item from the database

GetItemExclusive

Locks and returns a session item from the database

Initialize

Initializes the provider with the property values specified in the ASP.NET application configuration file

InitializeRequest

Performs any per-request initializations that the OracleSessionStateStore provider requires

ReleaseItemExclusive

Releases the lock on a session item in the database, if multiple attempts to retrieve the session item fail

RemoveItem

Removes the specified session item from the database

ResetItemTimeout

Resets the expiration date and timeout for a session item in the database

SetAndReleaseItemExclusive

Updates the session time information in the database with the specified session item and releases the lock

SetItemExpireCallback

Returns a false value to indicate that callbacks for expired sessions are not supported



OracleSessionStateStore Constructors

The OracleSessionStateStore constructor instantiates a new instance of the OracleSessionStateStore class.

Overload List:

OracleSessionStateStore()

This constructor instantiates a new instance of the OracleSessionStateStore class.

Declaration

// C#
public OracleSessionStateStore();

Remarks

This constructor creates a new instance of the OracleSessionStateStore class.


OracleSessionStateStore Public Properties

The OracleSessionStateStore public properties are listed in Table 5-4.

Table 5-4 OracleSessionStateStore Public Properties

Public Properties Description

CommandTimeout

Gets the number of seconds that the command is allowed to execute before it is terminated with an exception

Description

Inherited from System.Configuration.Provider.Providerbase

Name

Inherited from System.Configuration.Provider.Providerbase


CommandTimeout

This property gets the number of seconds that the command is allowed to execute before it is terminated with an exception.

Declaration

// C#
public int CommandTimeout {get;}
 

Property Value

An int.

Remarks

To customize a provider, ASP.NET developers can set an integer value for this property through the web.config file using the commandTimeout attribute.

The default value is 30 seconds. The attribute name in the configuration file is case-sensitive.


OracleSessionStateStore Public Methods

The OracleSessionStateStore public methods are listed in Table 5-5.

Table 5-5 OracleSessionStateStore Public Methods

Public Methods Description

CreateNewStoreData

Creates a new SessionStateStoreData object for the current request

CreateUninitializedItem

Adds a new session state item to the database

Dispose

Releases all the resources for this instance

EndRequest

Allows the OracleSessionStateStore object to perform any cleanup that may be required for the current request

GetItem

Returns a read-only session item from the database

GetItemExclusive

Locks and returns a session item from the database

Initialize

Initializes the provider with the property values specified in the ASP.NET application configuration file

InitializeRequest

Performs any per-request initializations that the OracleSessionStateStore provider requires

ReleaseItemExclusive

Releases the lock on a session item in the database, if multiple attempts to retrieve the session item fail

RemoveItem

Removes the specified session item from the database

ResetItemTimeout

Resets the expiration date and timeout for a session item in the database

SetAndReleaseItemExclusive

Updates the session time information in the database with the specified session item and releases the lock

SetItemExpireCallback

Returns a false value to indicate that callbacks for expired sessions are not supported


CreateNewStoreData

This method creates a new SessionStateStoreData object for the current request.

Declaration

// C#
public override SessionStateStoreData CreateNewStoreData(HttpContext context, 
   int timeout);

Parameters

Return Value

A new SessionStateStoreData object for the current request.

Remarks

This method creates a new SessionStateStoreData object for the current request based on the HttpContext and timeout values. The SessionStateModule calls this method at the beginning of a request for an ASP.NET page, if the request does not contain a session ID or if the request contains a session ID for a session that is not found in the database. This method creates a new SessionStateStoreData object with an empty ISessionStateItemCollection object, an HttpStaticObjectsCollection collection, and the specified timeout value.

CreateUninitializedItem

This method adds a new session state item to the database.

Declaration

// C#
public override void CreateUninitializedItem(HttpContext context, string id,
  int timeout);

Parameters

Exceptions

ArgumentNullException - The input parameter is null.

OracleException - An Oracle-related error has occurred.

Remarks

This method adds an uninitialized session state entry into the database and is called when the cookieless and regenerateExpiredId attributes are both set to true.

After a new session ID is created, this method is called to store an uninitialized entry with this new session ID in the database. The browser is redirected to the URL containing the new session ID. The new session ID exists in the database, so there is no conflict with an expired session ID.

Dispose

This method releases all the resources for this instance.

Declaration

// C#
public override void Dispose();

Remarks

This method releases all the resources for this instance when the application domain is closed.

EndRequest

This method allows the OracleSessionStateStore object to perform any cleanup that may be required for the current request.

Declaration

// C#
public override void EndRequest(HttpContext context);

Parameters

Remarks

This method is called by the SessionStateModule object at the end of a request.

GetItem

This method returns a read-only session item from the database.

Declaration

// C#
public override SessionStateStoreData GetItem(HttpContext context, string id, 
   out bool locked, out TimeSpan lockAge, out Object lockId, 
   out SessionStateActions actions);

Parameters

Return Value

A SessionStateStoreData object that contains session information from the database.

Exceptions

ArgumentNullException - The input parameter is null.

OracleException - An Oracle-related error has occurred.

System.Configuration.Provider.ProviderException - The session state information is invalid and might be corrupted.

Remarks

This method returns a read-only SessionStateStoreData object from the database and updates the expiration date of the session item. This method is called by the session state service at the beginning of a request. It is called only if the EnableSessionState attribute in the page is set to ReadOnly.

If no session data is found, then the locked out parameter is set to false and a null reference is returned. The session state service then calls the CreateNewStoreData method to create a new session item in the database.

If the session data is locked in the database, then the locked out parameter is set to true, the lockAge parameter is set to the amount of time the session item has been locked in the database, the lockId parameter is set to the lock identifier and a null reference is returned. The session state service then keeps calling this method at half-second intervals. If the lockAge value exceeds the HttpRuntimeSection.ExecutionTimeout value, then the session state service calls the ReleaseItemExclusive method to release the lock. It then calls the GetItem method again.

GetItemExclusive

This method locks a session item and returns it from the database.

Declaration

// C#
public override SessionStateStoreData GetItemExclusive(HttpContext context, 
   string id, out bool locked, out TimeSpan lockAge, out Object lockId, 
   out SessionStateActions actions);

Parameters

Return Value

A SessionStateStoreData object that contains session information from the database.

Exceptions

ArgumentNullException - The input parameter is null.

OracleException - An Oracle-related error has occurred.

System.Configuration.Provider.ProviderException - The session state information is invalid and might be corrupted.

Remarks

This method returns a SessionStateStoreData object from the database and updates the expiration date of the session item. This method is called only if the attribute in the page is set to the default value of true. The session item is retrieved only if no other requests are currently using it. The session item in the database is locked for the duration of the request.

If no session data is found, the locked out parameter is set to false and a null reference is returned. The session state service then calls the CreateNewStoreData method to create a newsession item in the database.

If the session data is locked in the database, then the locked parameter is set to true, the lockAge parameter is set to the amount of time the session item has been locked in the database, the lockId parameter is set to the lock identifier and a null reference is returned. The session state service then keeps calling this method at half-second intervals. If the lockAge value exceeds the ExecutionTimeout value, then the session state service calls the ReleaseItemExclusive method to release the lock. It then calls the GetItemExclusive method again.

Initialize

This method initializes the provider with the property values specified in the ASP.NET application configuration file (web.config).

Declaration

// C#
public override void Initialize(string name, NameValueCollection config);

Parameters

Exceptions

ArgumentNullException - The config parameter is null.

System.Configuration.Provider.ProviderException - The connectionStringName attribute is empty or does not exist in the configuration file, or an invalid attribute is found in the configuration file.

Remarks

The Initialize method is not intended to be called directly by the application.

InitializeRequest

This method performs any per-request initializations that the OracleSessionStateStore provider requires.

Declaration

// C#
public override void InitializeRequest(HttpContext context);

Parameters

Exceptions

ArgumentNullException - The context parameter is null.

Remarks

This method is called by the session state service before calling any other methods.

ReleaseItemExclusive

This method forcibly releases the lock on a session item in the database, if multiple attempts to retrieve the session item fail.

Declaration

// C#
public override void ReleaseItemExclusive(HttpContext context, string id,
    Object lockId);

Parameters

Exceptions

ArgumentNullException - The input parameter is null.

OracleException - An Oracle-related error has occurred.

Remarks

This method is called by the session state service to release the lock on a session item in the database and update the expiration date. The SessionStateModule calls this method at the end of a request if the session values are unchanged or when the lock has exceeded the HttpRuntimeSection.ExecutionTimeout property value.

RemoveItem

This method removes the specified session item from the database.

Declaration

// C#
public override void RemoveItem(HttpContext context, string id, Object lockId,
   SessionStateStoreData item);

Parameters

Exceptions

ArgumentNullException - The input parameter is null.

OracleException - An Oracle-related error has occurred.

Remarks

The session state service calls this method to remove the specified session item from the database. An application can call the Session.Abandon method to cancel a session.

ResetItemTimeout

This method resets the expiration date and timeout for a session item in the database.

Declaration

// C#
public override void ResetItemTimeout(HttpContext context, string id);

Parameters

Exceptions

ArgumentNullException - The input parameter is null.

OracleException - An Oracle-related error has occurred.

Remarks

The session state service calls this method to reset the expiration date and timeout for a session item in the database, to the current date and time.

SetAndReleaseItemExclusive

This method updates the session time information in the database with the specified session item, and releases the lock.

Declaration

// C#
public override void SetAndReleaseItemExclusive(HttpContext context, string id,
   SessionStateStoreDataItem item, Object lockId, bool newItem);

Parameters

Exceptions

ArgumentNullException - The input parameter is null.

OracleException - An Oracle-related error has occurred.

Remarks

If the session items have been modified, the session state service calls this method at the end of a request, to either create a new item or update an existing session item in the database with the provided session values. This method also updates the expiration time for the session item and releases the lock on the session data.

SetItemExpireCallback

This method returns a false value to indicate that callbacks for expired sessions are not supported.

Declaration

// C#
public override bool SetItemExpireCallback(SessionStateItemExpireCallback 
  expireCallback);

Parameters

Return Value

A false value.

Remarks

This method always returns a false value to indicate that callbacks for expired sessions are not supported.