string cmdstr = "a=123&b=456";
string url = "http://www.baidu.com/abc.aspx?do=getstring";
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(cmdstr);
WebRequest webrequest = WebRequest.Create(url);
webrequest.Method = "POST";
webrequest.Timeout = 30000;
webrequest.ContentType = "application/x-www-form-urlencoded";
webrequest.ContentLength = bytes.Length;
Stream ostreamOut = webrequest.GetRequestStream();
ostreamOut.Write(bytes, 0, bytes.Length);
ostreamOut.Close(); WebResponse response = webrequest.GetResponse();
Stream osResponse = response.GetResponseStream(); Encoding encode = Encoding.GetEncoding("utf-8");
StreamReader reader = new StreamReader(osResponse, encode);
Char[] readBuff = new Char[256];
int count = reader.Read(readBuff, 0, 256);
while (count > 0)
{
String outputdata = new String(readBuff, 0, count);
this.txtMessage.AppendText(outputdata);
count = reader.Read(readBuff, 0, 256);
}
response.Close();
reader.Close();
response.Close();abc.asxp页面中判断了
if(Requst.QuertString["do"]=="getstring")
{
string a=Request["a"];
string b=Request["b"];
////处理代码
Response.Clear();
Respost.wirte("123");
Respost.end();
}
这样处理,我用客户端程序POST发送a和b参数,到最后只返回个0,不知道为什么,求高手解答,谢谢了
string url = "http://www.baidu.com/abc.aspx?do=getstring";
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(cmdstr);
WebRequest webrequest = WebRequest.Create(url);
webrequest.Method = "POST";
webrequest.Timeout = 30000;
webrequest.ContentType = "application/x-www-form-urlencoded";
webrequest.ContentLength = bytes.Length;
Stream ostreamOut = webrequest.GetRequestStream();
ostreamOut.Write(bytes, 0, bytes.Length);
ostreamOut.Close(); WebResponse response = webrequest.GetResponse();
Stream osResponse = response.GetResponseStream(); Encoding encode = Encoding.GetEncoding("utf-8");
StreamReader reader = new StreamReader(osResponse, encode);
Char[] readBuff = new Char[256];
int count = reader.Read(readBuff, 0, 256);
while (count > 0)
{
String outputdata = new String(readBuff, 0, count);
this.txtMessage.AppendText(outputdata);
count = reader.Read(readBuff, 0, 256);
}
response.Close();
reader.Close();
response.Close();abc.asxp页面中判断了
if(Requst.QuertString["do"]=="getstring")
{
string a=Request["a"];
string b=Request["b"];
////处理代码
Response.Clear();
Respost.wirte("123");
Respost.end();
}
这样处理,我用客户端程序POST发送a和b参数,到最后只返回个0,不知道为什么,求高手解答,谢谢了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货