Mvc 用户没有登录跳转到登录界面

登录时增加:

Session["UserName"] = model.UserName;

Controller:

 protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            //这里判断出没有登录然后进行跳转
            if (this.Session["UserName"] == null)
            {
                Response.Redirect("/Account/Login");
            }
        }

 

posted @ 2015-10-29 08:38  gobuild  阅读(1300)  评论(0编辑  收藏  举报