第一次用DotNet.Utilities里的HttpHelper
[C#] 纯文本查看 复制代码 HttpHelper httpHelper = new HttpHelper();
HttpItem httpItem = new HttpItem()
{
URL = "http://localhost/test.aspx",
Method = "POST",
Postdata = "a=b"
};
HttpResult result = httpHelper.GetHtml(httpItem);
Debug.WriteLine(result.Html);
结果接收页死活接收不到post过去的参数,折腾了个把小时,发现问题在ContentType,HTTP协议定义了POST数据时,ContentType必须是 "application/x-www-form-urlencoded",但是HttpHelper不会自动处理这一点,需要手工指定
[C#] 纯文本查看 复制代码 httpItem.Method = "POST";
httpItem.ContentType = "application/x-www-form-urlencoded";
httpItem.Postdata = "a=b";
http://www.sufeinet.com/forum.php?mod=viewthread&tid=2766&ctid=23
这篇教程贴 4.最简单的Post与Get的写法 没有提到这个问题
这里提一下,说的不对的,大家指正
|