string idcard = this.labIdcard.Text.ToString(); string url = ConfigurationManager.AppSettings["apiIp"].ToString(); string action = "/api/action?" + idcard; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url + action); webRequest.ContentType = "text/json;charset="utf-8""; webRequest.Accept = "text/json"; webRequest.Method = "get"; var httpResponse = (HttpWebResponse)webRequest.GetResponse(); var streamReader = new StreamReader(httpResponse.GetResponseStream()); var result = streamReader.ReadToEnd(); JObject jo = (JObject)JsonConvert.DeserializeObject(result); string code = jo["code"].ToString(); if (code == "200") { BindList(); } string idcard = this.labIdcard.Text.ToString(); string url = ConfigurationManager.AppSettings["apiIp"].ToString(); string action = "/api/action?" + idcard; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url + action); webRequest.ContentType = "text/json;charset="utf-8""; webRequest.Accept = "text/json"; webRequest.Method = "post"; string json = new JavaScriptSerializer().Serialize(new { secret = secret, szdw = szdw }); //传参 byte[] buffer = Encoding.GetEncoding("UTF-8").GetBytes(json); Stream requestStream = webRequest.GetRequestStream(); requestStream.Write(buffer, 0, buffer.Length); requestStream.Close(); var httpResponse = (HttpWebResponse)webRequest.GetResponse(); var streamReader = new StreamReader(httpResponse.GetResponseStream()); var result = streamReader.ReadToEnd(); JObject jo = (JObject)JsonConvert.DeserializeObject(result); string code = jo["code"].ToString(); if (code == "200") { BindList(); }