Exemplo n.º 1
0
        protected void Session_Start(object sender, EventArgs e)
        {
            // event is raised each time a new session is created
            int currentValue = (int)AppStateHelper.Get(AppStateKeys.ONLINE, 0);

            AppStateHelper.Set(AppStateKeys.ONLINE, currentValue + 1);
            AppStateHelper.SetMultiple(new Dictionary <AppStateKeys, object> {
                { AppStateKeys.LAST_REQUEST_TIME, HttpContext.Current.Timestamp },
                { AppStateKeys.LAST_REQUEST_URL, this.Request.RawUrl }
            });
        }
Exemplo n.º 2
0
        protected void Session_End(object sender, EventArgs e)
        {
            // event is raised when a session is abandoned or expires
            int currentValue = (int)AppStateHelper.Get(AppStateKeys.ONLINE, 0);

            AppStateHelper.Set(AppStateKeys.ONLINE, currentValue - 1);
            AppStateHelper.SetMultiple(new Dictionary <AppStateKeys, object> {
                { AppStateKeys.LAST_REQUEST_TIME, HttpContext.Current.Timestamp },
                { AppStateKeys.LAST_REQUEST_URL, this.Request.RawUrl }
            });
        }
        public ActionResult Increment()
        {
            int currentValue = (int)AppStateHelper.Get(AppStateKeys.COUNTER, 0);

            AppStateHelper.Set(AppStateKeys.COUNTER, currentValue + 1);
            AppStateHelper.SetMultiple(new Dictionary <AppStateKeys, object> {
                { AppStateKeys.LAST_REQUEST_TIME, HttpContext.Timestamp },
                { AppStateKeys.LAST_REQUEST_URL, Request.RawUrl }
            });
            return(RedirectToAction("Index"));
        }