执行方法前 判断 sessin 登录信息 是否为空 ,空的话 返回 登录界面
并且给 LoginUser 赋值
public abstract class BaseController : Controller { public User LoginUser { get;private set; } protected RestResult Rest(object data) { return new RestResult(data); } protected override void OnActionExecuting(ActionExecutingContext filterContext) { LoginUser = Session["LoginUser"] as User; if (LoginUser == null) { Response.Redirect("system/index"); } base.OnActionExecuting(filterContext); } protected virtual void SetLoginUser(User user) { Session["LoginUser"] = user; } }