示例#1
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            string uid         = Utility.IO.Context.GetRequest("uid", string.Empty);
            string versionCode = Utility.IO.Context.GetRequest("versionCode", string.Empty);
            string deviceType  = Utility.IO.Context.GetRequest("deviceType", string.Empty);
            string timestamp   = Utility.IO.Context.GetRequest("timestamp", string.Empty);
            string sign        = Utility.IO.Context.GetRequest("sign", string.Empty);

            VerifyModel vmodel = new VerifyModel()
            {
                uid         = uid,
                versionCode = versionCode,
                deviceType  = deviceType,
                timestamp   = timestamp,
                sign        = sign
            };

            if (!vmodel.verify())
            {
                BaseResult res = new BaseResult();
                res.result  = false;
                res.msg     = "参数无效";
                res.errcode = 50082;
                ContentResult Respone_result = new ContentResult();
                Respone_result.Content = JsonConvert.SerializeObject(res);
                filterContext.Result   = Respone_result;
            }
        }
示例#2
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            string uid         = Utility.IO.Context.GetRequest("uid", string.Empty);
            string versionCode = Utility.IO.Context.GetRequest("versionCode", string.Empty);
            string deviceType  = Utility.IO.Context.GetRequest("deviceType", string.Empty);
            string timestamp   = Utility.IO.Context.GetRequest("timestamp", string.Empty);
            string sign        = Utility.IO.Context.GetRequest("sign", string.Empty);

            VerifyModel vmodel = new VerifyModel()
            {
                uid         = uid,
                versionCode = versionCode,
                deviceType  = deviceType,
                timestamp   = timestamp,
                sign        = sign
            };

            if (!vmodel.verify())
            {
                string[] keys   = System.Web.HttpContext.Current.Request.QueryString.AllKeys;
                string   values = string.Empty;
                if (keys.Length > 0)
                {
                    foreach (var item in keys)
                    {
                        values += string.Format("{0}={1}&", item, System.Web.HttpContext.Current.Request.QueryString[item]);
                    }
                }
                //string p="str=" + vmodel.CombinParameters() + ",md5=" + vmodel.MD5(vmodel.CombinParameters()) + ",des=" + vmodel.Encrypt(vmodel.MD5(vmodel.CombinParameters())) + ",keys=" + string.Join(",", keys) + ",values=" + values;
                filterContext.Result = new JsonResult()
                {
                    Data = new { isok = false, code = "-1", Msg = "非法请求" }
                };
            }
        }