标签:news class requests bre action urlencode web post tle
string postData = "Inputs={\"BarCode\":\"" + barCode + "\"}"; // 要发放的数据 //var str = JsonConvert.SerializeObject(postData); byte[] byteArray = Encoding.UTF8.GetBytes(postData); HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create("http://180.96.21.213:8890/action.ashx?action=IndexDetailInfosUrl"); objWebRequest.Method = "POST"; objWebRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8"; objWebRequest.ContentLength = byteArray.Length; objWebRequest.Headers.Add("Cookie", "companyid=XZGH"); //objWebRequest.CookieContainer = myCookieContainer; Stream newStream = objWebRequest.GetRequestStream(); newStream.Write(byteArray, 0, byteArray.Length); //写入参数 newStream.Close(); HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string textResponse = sr.ReadToEnd(); // 返回的数据 return textResponse;
标签:news class requests bre action urlencode web post tle
原文地址:http://www.cnblogs.com/kunlunmountain/p/6881699.html