コード例 #1
0
        public ActionResult Login(string userName, string passWord)
        {
            if (userName == string.Empty || passWord == string.Empty)
            {
                return(Content("<script>alert('用户名和密码不可以为空');history.go(-1);</script>"));
            }
            var booLogin = iUserDal.LoadEntity(u => u.UserName == userName).FirstOrDefault();

            if (booLogin != null)
            {
                if (booLogin.UserPassword == passWord)
                {
                    //登录状态
                    Session["UserLogin"] = booLogin;
                    //设置超时
                    Session.Timeout = 10;
                    return(Content("<script >alert('登录成功,正在转到主页...');window.location.href = 'Index';</script >", "text/html"));
                }
                else
                {
                    return(Content("<script>alert('请检查您的账号密码是否正确');history.go(-1);</script>"));
                }
            }
            return(Content("<script>alert('请检查您的账号密码是否正确');history.go(-1);</script>"));
        }