コード例 #1
0
        public ActionResult Logoff()
        {
            if (SiteSession.IsValid())
            {
                SiteSession.Current.Clear();
                Session.Abandon();
            }

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var controllerName = filterContext.RouteData.Values["controller"];
            var actionName     = filterContext.RouteData.Values["action"];
            var message        = String.Format("{0} controller:{1} action:{2}", "onactionexecuting", controllerName, actionName);

            Debug.WriteLine(message, "Action Filter Log");
            if (!SiteSession.IsValid())
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                {
                    controller = "Home",
                    action     = "SessionExpired"
                }));
                return;
            }
            base.OnActionExecuting(filterContext);
        }