![]() RemoveHttpSessionStateFromContext(HttpContext) RaiseSessionEnd(IHttpSessionState, Object, EventArgs)Įxecutes the Session_OnEnd event defined in the Global.asax file for the ASP.NET application. Gets a value which indicates whether the session state is required for the specified HttpContext. Gets a value which indicates whether the session state is read-only for the specified HttpContext. Gets a reference to the static objects collection for the specified context. Retrieves session data from the context for the current request. GetHttpSessionStateFromContext(HttpContext) Gets or sets a serialization surrogate selector that is used for session serialization customization.ĪddHttpSessionStateToContext(HttpContext, IHttpSessionState)Īpplies the session data to the context for the current request. Session data is passed to and retrieved from the current HttpContext as an HttpSessionStateContainer object or any valid implementation of the IHttpSessionState interface.įor information about implementing a session-state store provider, see Implementing a Session-State Store Provider. The HttpStaticObjectsCollection collection returned is included with the session data added to the current HttpContext. MethodĬan be used by custom session-state modules to either retrieve session information for an existing session or create session information for a new session.Ĭalled by the session-state module to add the session data to the current HttpContext and make it available to application code through the Session property.Ĭalled by the session-state module during the ReleaseRequestState or EndRequest events at the end of a request, to clear session data from the current HttpContext.Ĭalled by the session-state module to get a reference to the StaticObjects collection based on objects defined in the Global.asax file. The following table describes the ways the session-state module and session-state store provider use the methods. ![]() Application developers will not need to call these methods from their code. The SessionStateUtility class provides static helper methods that are used by a session-state module or a session-state store provider. If ( DateTime.Compare(item.Expires, DateTime.Now) SessionItem item = (SessionItem)entry.Value Recursivly remove expired session data from session collection.įoreach (DictionaryEntry entry in pSessionItems) PHashtableLock.AcquireWriterLock(Int32.MaxValue) expired sessions and remove expired data. Called periodically by the Timer created in the Init method to check for PConfig = (SessionStateSection)cfg.GetSection("system.web/sessionState") WebConfigurationManager.OpenWebConfiguration(.ApplicationVirtualPath) Get the configuration section and set timeout and CookieMode values. PTimer = new Timer(new TimerCallback(this.ExpireCallback), Create a Timer to invoke the ExpireCallback method based on If not already initialized, initialize timer and configuration. PSessionIDManager = new SessionIDManager() Internal HttpStaticObjectsCollection StaticObjects Īpp.AcquireRequestState += new EventHandler(this.OnAcquireRequestState) Īpp.ReleaseRequestState += new EventHandler(this.OnReleaseRequestState) Internal SessionStateItemCollection Items periodically by the local Timer to check for all expired SessionItem objects in the in the OnAcquireRequestState event handler. in the OnReleaseRequestState event handler and retrieved from the local Hashtable SessionItem objects are added to the local Hashtable The SessionItem class is used to store data for a particular session along with Private ISessionIDManager pSessionIDManager Private ReaderWriterLock pHashtableLock = new ReaderWriterLock() Private HttpCookieMode pCookieMode = HttpCookieMode.UseCookies Private Hashtable pSessionItems = new Hashtable() Public sealed class MySessionStateModule : IHttpModule, IDisposable This application does not prevent simultaneous Web requests from using the same session identifier. The module uses the SessionStateUtility class to reference the current HttpContext and SessionIDManager, retrieve the current HttpStaticObjectsCollection, and raise the Session_OnEnd event defined in the Global.asax file for the ASP.NET application. The following code example shows a custom session-state module implementation that stores session information in memory using a Hashtable.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |