登录时增加:
Session["UserName"] = model.UserName;
Controller:
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); //这里判断出没有登录然后进行跳转 if (this.Session["UserName"] == null) { Response.Redirect("/Account/Login"); } }
时间: 2024-08-07 09:27:53