Uredi

Deli z drugimi prek


SessionStateStoreProviderBase.GetItem Method

Definition

Returns read-only session-state data from the session data store.

public:
 abstract System::Web::SessionState::SessionStateStoreData ^ GetItem(System::Web::HttpContext ^ context, System::String ^ id, [Runtime::InteropServices::Out] bool % locked, [Runtime::InteropServices::Out] TimeSpan % lockAge, [Runtime::InteropServices::Out] System::Object ^ % lockId, [Runtime::InteropServices::Out] System::Web::SessionState::SessionStateActions % actions);
public abstract System.Web.SessionState.SessionStateStoreData GetItem (System.Web.HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out System.Web.SessionState.SessionStateActions actions);
abstract member GetItem : System.Web.HttpContext * string * bool * TimeSpan * obj * SessionStateActions -> System.Web.SessionState.SessionStateStoreData
Public MustOverride Function GetItem (context As HttpContext, id As String, ByRef locked As Boolean, ByRef lockAge As TimeSpan, ByRef lockId As Object, ByRef actions As SessionStateActions) As SessionStateStoreData

Parameters

context
HttpContext

The HttpContext for the current request.

id
String

The SessionID for the current request.

locked
Boolean

When this method returns, contains a Boolean value that is set to true if the requested session item is locked at the session data store; otherwise, false.

lockAge
TimeSpan

When this method returns, contains a TimeSpan object that is set to the amount of time that an item in the session data store has been locked.

lockId
Object

When this method returns, contains an object that is set to the lock identifier for the current request. For details on the lock identifier, see "Locking Session-Store Data" in the SessionStateStoreProviderBase class summary.

actions
SessionStateActions

When this method returns, contains one of the SessionStateActions values, indicating whether the current session is an uninitialized, cookieless session.

Returns

A SessionStateStoreData populated with session values and information from the session data store.

Examples

For an example of a session-state store provider implementation, see Implementing a Session-State Store Provider.

Remarks

The SessionStateModule object calls the GetItem method at the beginning of a request, during the AcquireRequestState event, when the EnableSessionState attribute is set to ReadOnly. If the EnableSessionState attribute is set to true, the SessionStateModule object instead calls the GetItemExclusive method.

The GetItem method returns a SessionStateStoreData object populated with session information from the data store and updates the expiration date of the session data. If no session-item data is found at the data store, the GetItem method sets the locked out parameter to false and returns null. This causes the SessionStateModule object to call the CreateNewStoreData method to create a new session item in the data store.

If session-item data is found at the data store but the data is locked, the GetItem method sets the locked out parameter to true, sets the lockAge out parameter to the current date and time minus the date and time when the item was locked (which is retrieved from the data store), sets the lockId out parameter to the lock identifier retrieved from the data store, and returns null. This causes the SessionStateModule object to call the GetItem method again after a half-second interval to attempt to retrieve the session-item information.

If the value that the lockAge out parameter is set to exceed the ExecutionTimeout value, then the SessionStateModule object calls the ReleaseItemExclusive method to clear the lock on the session-item data, and then calls the GetItem method again.

The actionFlags parameter is used when both the cookieless and regenerateExpiredSessionId attributes are set to true. An actionFlags value set to InitializeItem indicates that the entry in the session data store is a new session that requires initialization. Uninitialized entries in the session data store are created by a call to the CreateUninitializedItem method. If the item from the session data store is not an uninitialized item, the actionFlags parameter will be set to zero.

Custom session-state store implementers that support cookieless sessions should set the actionFlags out parameter to the value returned from the session data store for the current item. If the actionFlags parameter value for the requested session-store item equals the InitializeItem enumeration value, then the GetItem method should set the value in the data store to zero after setting the actionFlags out parameter.

Applies to

See also