测试通过,请求的为自己写的一般处理程序,代码如下:
代码
Encoding myEncoding
=
Encoding.GetEncoding(
"
gb2312
"
);
string param = HttpUtility.UrlEncode( " aa " , myEncoding) + " = " +
HttpUtility.UrlEncode( " 值A " , myEncoding);
byte [] bs = Encoding.UTF8.GetBytes(param);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create( " http://xxxx.com " );
req.Method = " POST " ;
req.UserAgent = " Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322) " ;
req.ContentType = " application/x-www-form-urlencoded;charset=gb2312 " ;
req.ContentLength = bs.Length;
Stream reqStream = req.GetRequestStream();
reqStream.Write(bs, 0 , bs.Length);
reqStream.Close();
WebResponse myWebResponse = req.GetResponse();
using (StreamReader sr = new StreamReader(myWebResponse.GetResponseStream(), myEncoding))
{
// 返回结果
Response.Write(sr.ReadToEnd());
}
string param = HttpUtility.UrlEncode( " aa " , myEncoding) + " = " +
HttpUtility.UrlEncode( " 值A " , myEncoding);
byte [] bs = Encoding.UTF8.GetBytes(param);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create( " http://xxxx.com " );
req.Method = " POST " ;
req.UserAgent = " Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322) " ;
req.ContentType = " application/x-www-form-urlencoded;charset=gb2312 " ;
req.ContentLength = bs.Length;
Stream reqStream = req.GetRequestStream();
reqStream.Write(bs, 0 , bs.Length);
reqStream.Close();
WebResponse myWebResponse = req.GetResponse();
using (StreamReader sr = new StreamReader(myWebResponse.GetResponseStream(), myEncoding))
{
// 返回结果
Response.Write(sr.ReadToEnd());
}
如果本文对你有所帮助,请打赏——1元就足够感动我:)
联系邮箱:intdb@qq.com
我的GitHub: https://github.com/vipstone
联系邮箱:intdb@qq.com
我的GitHub: https://github.com/vipstone
关注公众号:
作者: 王磊
出处: http://vipstone.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,请标明出处。