public void GetPreCode() { string url = string.Empty; try { string host = "hexiaodong.top/"; string path = "api/pay/code"; string redirect_uri = HttpUtility.UrlEncode("http://" + host + path); WeChatPayData data = new WeChatPayData(); data.SetValue("appid", WeChatConfig.APP_ID); data.SetValue("redirect_uri", redirect_uri); data.SetValue("response_type", "code"); data.SetValue("scope", "snsapi_userinfo"); //data.SetValue("connect_redirect", "1"); data.SetValue("state", "1" + "#wechat_redirect"); url = "https://open.weixin.qq.com/connect/oauth2/authorize?" + data.ToUrl(); _logger.Info("url地址为:" + url); } catch (Exception ex) { _logger.Info("错误信息为:" + ex); } ControllerContext.HttpContext.Response.Redirect(url); //var client = new RestClient(url) //{ // UserAgent = "Mozilla/5.0 (Linux; Android 6.0; 1503-M02 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036558 Safari/537.36 MicroMessenger/6.3.25.861 NetType/WIFI Language/zh_CN", // Encoding = Encoding.UTF8 //}; }