protected override string GetAjaxResult(HttpContext context)
        {
            string timeStamp = GetTimestamp();                                    //生成签名的时间戳
            string noncestr  = GetNoncestr();                                     //生成签名的随机串
            string page      = context.Request["Pagepath"];
            string url       = "http://" + context.Request.Url.Host + "/" + page; //当前的地址
            string appid     = "*****";

            string jsapiTicke = GetJsapiTicket();//获取ticket

            string[] arrayList = { "jsapi_ticket=" + jsapiTicke, "timestamp=" + timeStamp, "noncestr=" + noncestr, "url=" + url };
            Array.Sort(arrayList);
            string sign = string.Join("&", arrayList);

            UnionLog.WriteLog(LogType.UNION_INFO, "加密前的签名:" + sign);
            sign = FormsAuthentication.HashPasswordForStoringInConfigFile(sign, "SHA1").ToLower();
            UnionLog.WriteLog(LogType.UNION_INFO, "加密后的签名:" + sign);
            var obj = new
            {
                appId     = appid,
                timestamp = timeStamp,
                nonceStr  = noncestr,
                signature = sign
            };
            string rst = JsonConvert.SerializeObject(obj);

            UnionLog.WriteLog(LogType.UNION_INFO, "JS-SDK注册wxconfig参数:" + rst);
            return(rst);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var gbk = Encoding.GetEncoding("gbk").CodePage;
            //var url = "http://test.telefen.com/HGSecKill/ajax/OrderCreate.ashx?";
            var url = "http://localhost:4915/ajax/SendRandomHandler.ashx";

            CookieContainer myCookieContainer = new CookieContainer();
            //var cookieStr = myCookieContainer.GetCookies(new Uri("http://test.telefen.com")).Replace(" ", "");
            //cookieStr = cookieStr.Replace(";", ",");

            //var cc = new CookieContainer();
            //cc.SetCookies(new Uri("http://test.telefen.com"), cookieStr);


            //string cookieValue = "Set-Cookie:UserToken=VA4vpmdbKOw8HYSR3Z03VrKyaRoLGCHlcC+IdrtX9PUTV8TtU1ZWekFDxedUuAVFCnl5iQQfXyKv6QKPXJ0iEp5sbMuzWcVpaLGMMZoA+ObrvQ/g/E1+svNxv++sUV1p;Expires=2016-10-28T12:58:15.548Z;Path=/;Domain=test.telefen.com;";
            //myCookieContainer.SetCookies(new Uri("http://test.telefen.com"), cookieValue);
            //Parallel.For(0, 1000, item =>
            //{
            string nohtmlStr = HttpHelper.HttpJsonPost(url, "appCode=102387");

            UnionLog.WriteLog(LogType.UNION_INFO, "接口返回:" + nohtmlStr);
            //});

            Response.Write("测试结束!");
        }