public ActionResult Login([Bind(Include = "UserName,Password")] string UserName, string Password) { try { var users = usersmanager.Denglu(UserName, Password); if (users != null) { //保存到Session HttpContext. Session["UserName"] = users.UserName; Session["UserID"] = users.UserID; Session["HeadPic"] = users.HeadPic; return(Content("<script>;alert('登录成功!返回首页!');window.location.href='/Home/Index'</script>")); } else { return(Content("<script>;alert('该账号不存在或者密码错误!');history.go(-1)</script>")); } } catch (Exception ex) { return(Content(ex.Message)); } }