コード例 #1
0
        private string saveUser(HttpContext context)
        {
            string username = context.Request.Params.Get("username");
            string password = context.Request.Params.Get("password");
            string email = context.Request.Params.Get("email");
            string tel = context.Request.Params.Get("mobile");
            if (StringHelper.IsEmpty(username))
            {
                throw new Exception("用户名不能为空。");
            }

            if (StringHelper.IsEmpty(password))
            {
                throw new Exception("密码不能为空。");
            }

            if (StringHelper.IsEmpty(email))
            {
                throw new Exception("邮箱地址不能为空。");
            }

            if (StringHelper.IsEmpty(tel))
            {
                throw new Exception("手机号不能为空。");
            }

            UserModel user = new UserModel();
            user.username = username;
            user.email = email;
            user.tel = tel;
            user.password = password;

            UserBll userBll = new UserBll();
            if (userBll.SaveUser(user))
            {
                return "ok";
            }
            else
            {
                throw new Exception("数据库异常,新用户保存失败。");
            }
        }
コード例 #2
0
ファイル: Login.ashx.cs プロジェクト: qingchen191/workspace
        public void ProcessRequest(HttpContext context)
        {
            string username = context.Request.Params.Get("username");
            string password = context.Request.Params.Get("password");
            string rtnStr = "";

            UserBll userBll = new UserBll();
            UserModel user = userBll.GetModelByName(username);
            if (user.password.Equals(password))
            {
                rtnStr = "ok";
            }
            else
            {
                rtnStr = "用户名或者密码错误。";
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write("{\"resStatus\":\"" + rtnStr + "\"}");
            context.Response.Flush();
            context.Response.End();
        }