/// <summary> /// When using session stateServer or sqlserver mode, session_end is unavailable. /// Must use this modified module to keep track of session end. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void SessionTimoutModule_SessionEnd(object sender, SessionEndedEventArgs e) { Debug.WriteLine("SessionTimoutModule_SessionEnd : SessionId : " + e.SessionId); // This will be the value in the session for the key specified in Application_Start ShoppingCartModel shoppingCart = e.SessionObject as ShoppingCartModel; Debug.WriteLine("Returned value: " + shoppingCart.totalItems); }
/// <summary> /// This method is fired when an item is removed from the cache. It is used to detect when a cache item /// expires, indicating that the session has expired, and fires the SessionEnd event. /// </summary> private void CacheItemRemovedCallbackMethod(string key, object value, CacheItemRemovedReason reason) { if (reason == CacheItemRemovedReason.Expired) { if (SessionEnd != null) { SessionEndedEventArgs e = new SessionEndedEventArgs(key, value); SessionEnd(this, e); } } }