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

  • context

    The HttpContext object for the current request.

  • timeout

    The timeout value for the SessionStateStoreData object that is created.

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

  • context

    The HttpContext object for the current request.

  • id

    The session ID for the current request.

  • timeout

    The timeout value for the current request.

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

  • context

    The HttpContext object for the current request.

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

  • context

    The HttpContext object for the current request.

  • id

    The session ID for the current request.

  • locked

    A Boolean value that is true if the session item is locked in the database; otherwise, it is false.

  • lockAge

    A a TimeSpan object that indicates the amount of time the session item has been locked in the database.

  • lockId

    A lock identifier object.

  • actions

    A SessionStateActions enumeration value that indicates whether the session is uninitialized and cookieless.

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

  • context

    The HttpContext object for the current request.

  • id

    The session ID for the current request.

  • locked

    A Boolean value that is true if the session item was successfully locked in the database; otherwise, it is false.

  • lockAge

    A TimeSpan object that indicates the amount of time the session item has been locked in the database.

  • lockId

    A lock identifier object.

  • actions

    A SessionStateActions enumeration value that indicates whether the session is uninitialized and cookieless.

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

  • name

    The name of the provider instance to initialize.

  • config

    A Systems.Collections.Specialized.NameValueCollection object that contains the names and values of configuration options for the provider.

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

  • context

    The HttpContext object for the current request.

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

  • context

    The HttpContext object for the current request.

  • id

    The session ID for the current request.

  • lockId

    The lock identifier for the current request.

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

  • context

    The HttpContext object for the current request.

  • id

    The session ID for the current request.

  • lockId

    The lock identifier for the current request.

  • item

    The session item to remove from the database.

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

  • context

    The HttpContext object for the current request.

  • id

    The session ID for the current request.

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

  • context

    The HttpContext object for the current request.

  • id

    The session ID for the current request.

  • item

    The session item containing new values to update the session item in the database with.

  • LockId

    The lock identifier for the current request.

  • newItem

    A Boolean value that indicates whether the session item is new in the database. A false value indicates an existing item.

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

  • expireCallback

    The delegate for the Session_OnEnd event defined in the Global.asax file.

Return Value

A false value.

Remarks

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