http发送和接受数据问题,大家帮忙看下!!!!
string param = string.Format("checkName={0}&checkCompany={1}&userName={2}&userNum={3}&userAddress{4}", this.EncodeConver(checkName), this.EncodeConver(checkCompany), this.EncodeConver(userName), this.EncodeConver(userNum), this.EncodeConver(userAddress));//所发送的数据
string result = this.SendRequest(param);
public string SendRequest(string param)
{
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(param);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("www.xxx.com"); //数据发送端口
request.Method = "POST";//发送方式
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream sm = request.GetRequestStream();
sm.Write(data, 0, data.Length);
sm.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
这个地方 获取返回值,如果返回值是 OK就继续操作
if (response.StatusCode.ToString() != "OK") //还未获取返回值
...
}
但是 厂商那边 只返回 一个WEB页面,并不是返回给我一个字符串,而且 WEB页面是什么 也没说。
我这里想 获取这个URL的body, 如果这个body里面的内容不为空, 那么就证明他给了我返回,也就是说我数据发送成功了
这个获取 body的 内容不为空 应该如何来写, 这里卡住了,不知道如何下手
请大家帮帮忙!!!