首页 > 代码库 > Httprequest 添加Cookie
Httprequest 添加Cookie
string postData = http://www.mamicode.com/"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;
Httprequest 添加Cookie
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。