protected override void OnAuthorization(AuthorizationContext filterContext) { log.Info(this.GetType() + "OnAuthorization"); var session = new BLSessionPersisiter(); filterContext.HttpContext.User = new MyPrincipal( new MyIdentity(session.UserID)); base.OnAuthorization(filterContext); }
public ActionResult MyLogin(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var bll = BLLFactory.Create <I房屋租赁表BL>(); var query = bll.QueryAll(); var user = BLLFactory.Create <IBASE_USERBL>().GetByAccount(model.name, model.Password); if (user != null) { BLSessionPersisiter session = new BLSessionPersisiter(); session.UserID = user.Emp_ID.Value; session.UserName = user.UserAccount; return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", "无效的登录尝试。"); return(View(model)); } }