Exemplo n.º 1
0
        /// <summary>
        /// 验证Geetest验证码
        /// </summary>
        /// <returns></returns>
        public JsonResult ValidateGeetestCode()
        {
            var geetestRequest = new GeetestRequestModel
            {
                challenge = Request[GeetestConsts.FnGeetestChallenge],
                validate  = Request[GeetestConsts.FnGeetestValidate],
                seccode   = Request[GeetestConsts.FnGeetestSeccode]
            };

            return(Json(new GeetestHelper()
                        .ValidateRequest(geetestRequest,
                                         Session[GeetestConsts.GeetestUserId]?.ToString() ?? "",
                                         Convert.ToByte(Session[GeetestConsts.GtServerStatusSessionKey]),
                                         () => { Session.Remove(GeetestConsts.GeetestUserId); })));
        }
        /// <summary>
        /// 验证Geetest验证码
        /// </summary>
        /// <returns></returns>
        public JsonResult ValidateGeetestCode()
        {
            var geetestRequest = new GeetestRequestModel
            {
                challenge = Request.Form[GeetestConsts.FnGeetestChallenge],
                validate  = Request.Form[GeetestConsts.FnGeetestValidate],
                seccode   = Request.Form[GeetestConsts.FnGeetestSeccode]
            };

            return(Json(HttpContext.RequestServices.GetRequiredService <GeetestHelper>()
                        .ValidateRequest(geetestRequest,
                                         HttpContext.Session.GetString(GeetestConsts.GeetestUserId)?.ToString() ?? "",
                                         Convert.ToByte(HttpContext.Session.GetString(GeetestConsts.GtServerStatusSessionKey)),
                                         () => { HttpContext.Session.Remove(GeetestConsts.GeetestUserId); })));
        }