发送请求的代码如下:
//发送请求
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(service);
myRequest.Method = "POST";
myRequest.ContentType = contenttype;
myRequest.ContentLength = para.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
ASCIIEncoding encoding = new ASCIIEncoding(); //Byte[] bb = Encoding.GetEncoding("GBK").GetBytes(para); ;
byte[] postdata = encoding.GetBytes(para);
//byte[] postdata = Encoding.Default.GetBytes(para);
newStream.Write(postdata, 0, para.Length);
//newStream.Write(bb, 0, para.Length);
newStream.Close();
//发送请求
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(service);
myRequest.Method = "POST";
myRequest.ContentType = contenttype;
myRequest.ContentLength = para.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
ASCIIEncoding encoding = new ASCIIEncoding(); //Byte[] bb = Encoding.GetEncoding("GBK").GetBytes(para); ;
byte[] postdata = encoding.GetBytes(para);
//byte[] postdata = Encoding.Default.GetBytes(para);
newStream.Write(postdata, 0, para.Length);
//newStream.Write(bb, 0, para.Length);
newStream.Close();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货