public ActionResult Login(Users data) { try { UserDbContext uc = new UserDbContext("ConnStr1"); Users user = uc.Login(data.UserAccount, data.UserPwd, Enum_LoginMethod.UserAccount); string tickStr = string.Empty; if (user != null) { tickStr = "登录成功。"; SessionManager.User = user; SessionManager.UserName = user.UserName; SessionManager.UserID = user.UserID; string script = MvcUT.Href(this, "Index", null); return(Content(script)); } else { SessionManager.User = null; SessionManager.UserName = string.Empty; SessionManager.UserID = string.Empty; tickStr = "登录失败,请检查账户与密码是否有误?"; string script = MvcUT.ShowAlertAndHref(this, tickStr, "Login", null); return(Content(script)); } } catch (Exception ex) { if (ex.Message != null) { } this.ViewBag.ErrMsg = MisBase.BaseUT.GetRootException(ex).Message; return(View(data)); } }