Oracle® Providers for ASP.NET Developer's Guide 11g Release 2 (11.2.0.3) for Microsoft Windows Part Number E18737-02 |
|
|
PDF · Mobi · ePub |
The OracleSessionStateStore
class allows ASP.NET applications to store session information in an Oracle database.
System.Object
System.Configuration.Provider.ProviderBase
System.Web.SessionState.SessionStateStoreProviderBase
Oracle.Web.SessionState
// C# public class OracleSessionStateStore : SessionStateStoreProviderBase
All public static methods are thread-safe, although instance members are not guaranteed to be thread-safe.
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.
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>
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
See Also:
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 |
---|---|
Instantiates a new instance of the |
OracleSessionStateStore Public Properties
OracleSessionStateStore
public properties are listed in Table 5-2.
Table 5-2 OracleSessionStateStore Public Properties
Public Properties | Description |
---|---|
Gets the number of seconds that the command is allowed to execute before it is terminated with an exception |
|
|
Inherited from |
|
Inherited from |
OracleSessionStateStore Public Methods
The OracleSessionStateStore
public methods are listed in Table 5-3.
Table 5-3 OracleSessionStateStore Public Methods
Public Methods | Description |
---|---|
Creates a new |
|
Adds a new session state item to the database |
|
Releases all the resources for this instance |
|
Allows the |
|
Returns a read-only session item from the database |
|
Locks and returns a session item from the database |
|
Initializes the provider with the property values specified in the ASP.NET application configuration file |
|
Performs any per-request initializations that the |
|
Releases the lock on a session item in the database, if multiple attempts to retrieve the session item fail |
|
Removes the specified session item from the database |
|
Resets the expiration date and timeout for a session item in the database |
|
Updates the session time information in the database with the specified session item and releases the lock |
|
Returns a |
The OracleSessionStateStore
constructor instantiates a new instance of the OracleSessionStateStore
class.
This constructor creates an instance of the OracleSessionStateStore
class.
See Also:
This constructor instantiates a new instance of the OracleSessionStateStore
class.
// C# public OracleSessionStateStore();
This constructor creates a new instance of the OracleSessionStateStore
class.
See Also:
The OracleSessionStateStore
public properties are listed in Table 5-4.
Table 5-4 OracleSessionStateStore Public Properties
Public Properties | Description |
---|---|
Gets the number of seconds that the command is allowed to execute before it is terminated with an exception |
|
|
Inherited from |
|
Inherited from |
See Also:
This property gets the number of seconds that the command is allowed to execute before it is terminated with an exception.
// C# public int CommandTimeout {get;}
An int
.
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.
See Also:
The OracleSessionStateStore
public methods are listed in Table 5-5.
Table 5-5 OracleSessionStateStore Public Methods
Public Methods | Description |
---|---|
Creates a new |
|
Adds a new session state item to the database |
|
Releases all the resources for this instance |
|
Allows the |
|
Returns a read-only session item from the database |
|
Locks and returns a session item from the database |
|
Initializes the provider with the property values specified in the ASP.NET application configuration file |
|
Performs any per-request initializations that the |
|
Releases the lock on a session item in the database, if multiple attempts to retrieve the session item fail |
|
Removes the specified session item from the database |
|
Resets the expiration date and timeout for a session item in the database |
|
Updates the session time information in the database with the specified session item and releases the lock |
|
Returns a |
See Also:
This method creates a new SessionStateStoreData
object for the current request.
// C# public override SessionStateStoreData CreateNewStoreData(HttpContext context, int timeout);
context
The HttpContext
object for the current request.
timeout
The timeout value for the SessionStateStoreData
object that is created.
A new SessionStateStoreData
object for the current request.
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.
See Also:
This method adds a new session state item to the database.
// C# public override void CreateUninitializedItem(HttpContext context, string id, int timeout);
context
The HttpContext
object for the current request.
id
The session ID for the current request.
timeout
The timeout value for the current request.
ArgumentNullException
- The input parameter is null.
OracleException
- An Oracle-related error has occurred.
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.
See Also:
This method releases all the resources for this instance.
// C# public override void Dispose();
This method releases all the resources for this instance when the application domain is closed.
See Also:
This method allows the OracleSessionStateStore
object to perform any cleanup that may be required for the current request.
// C#
public override void EndRequest(HttpContext context);
context
The HttpContext
object for the current request.
This method is called by the SessionStateModule
object at the end of a request.
See Also:
This method returns a read-only session item from the database.
// C# public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out Object lockId, out SessionStateActions actions);
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 or not the session is uninitialized and cookieless.
A SessionStateStoreData
object that contains session information from the database.
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.
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.
See Also:
This method locks a session item and returns it from the database.
// C# public override SessionStateStoreData GetItemExclusive(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out Object lockId, out SessionStateActions actions);
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 or not the session is uninitialized and cookieless.
A SessionStateStoreData
object that contains session information from the database.
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.
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.
See Also:
This method initializes the provider with the property values specified in the ASP.NET application configuration file (web.config
).
// C# public override void Initialize(string name, NameValueCollection config);
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.
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.
The Initialize
method is not intended to be called directly by the application.
See Also:
This method performs any per-request initializations that the OracleSessionStateStore
provider requires.
// C#
public override void InitializeRequest(HttpContext context);
context
The HttpContext
object for the current request.
ArgumentNullException
- The context
parameter is null.
This method is called by the session state service before calling any other methods.
See Also:
This method forcibly releases the lock on a session item in the database, if multiple attempts to retrieve the session item fail.
// C# public override void ReleaseItemExclusive(HttpContext context, string id, Object lockId);
context
The HttpContext
object for the current request.
id
The session ID for the current request.
lockId
The lock identifier for the current request.
ArgumentNullException
- The input parameter is null.
OracleException
- An Oracle-related error has occurred.
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.
See Also:
This method removes the specified session item from the database.
// C# public override void RemoveItem(HttpContext context, string id, Object lockId, SessionStateStoreData item);
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.
ArgumentNullException
- The input parameter is null.
OracleException
- An Oracle-related error has occurred.
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.
See Also:
This method resets the expiration date and timeout for a session item in the database.
// C# public override void ResetItemTimeout(HttpContext context, string id);
context
The HttpContext
object for the current request.
id
The session ID for the current request.
ArgumentNullException
- The input parameter is null.
OracleException
- An Oracle-related error has occurred.
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.
See Also:
This method updates the session time information in the database with the specified session item, and releases the lock.
// C# public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreDataItem item, Object lockId, bool newItem);
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 or not the session item is new in the database. A false
value indicates an existing item.
ArgumentNullException
- The input parameter is null.
OracleException
- An Oracle-related error has occurred.
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.
See Also:
This method returns a false
value to indicate that callbacks for expired sessions are not supported.
// C#
public override bool SetItemExpireCallback(SessionStateItemExpireCallback
expireCallback);
expireCallback
The delegate for the Session_OnEnd
event defined in the Global.asax
file.
A false
value.
This method always returns a false
value to indicate that callbacks for expired sessions are not supported.