今天刚开始使用这个类
-------------这是对方网站页面里的源码---------------
$.ajax({
type: "POST",
contentType: "application/json",
url: "./Countdown",
cache: false,
dataType: "json",
success: (function (data) { data 是一串json格式的数据
略.....
})
})
--------------返回的是一串JSON 数据---------
我模仿着写了下
[C#] 纯文本查看 复制代码 HttpItem i = new HttpItem();
HttpHelper hh = new HttpHelper();
i.Method = "POST";
i.PostDataType = PostDataType.String; // 这里按说明说要提交 PostData数据 但是如果是空的怎么提交?
i.URL = "http://www.1234.com/Countdown";
i.Accept = "application/json, text/javascript, */*; q=0.01"; //从firebug 里复制的
i.ContentType = "application/json"; //从firebug 里复制的
i.Host = "www.1234.com";
i.Referer = "http://www.1234.com";
HttpResult rr = hh.GetHtml(i);
MessageBox.Show(rr.Html);
结果rr.Html里的内容是
[HTML] 纯文本查看 复制代码 <BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
不知道是哪里不对 @站长苏飞
-------------------------
---下面是firebug里查看到的头信息和请求信息-----------------
响应头信息
Cache-Control | max-age=172800 | Connection | keep-alive | Content-Encoding | gzip | Content-Length | 488 | Content-Type | application/json; charset=utf-8 | Date | Sat, 10 Oct 2015 08:41:57 GMT | Expires | Mon, 12 Oct 2015 08:41:57 GMT | Last-Modified | Sat, 10 Oct 2015 08:42:31 GMT | Server | nginx/1.2.9 | Vary | *,Accept-Encoding | X-AspNet-Version | 4.0.30319 | X-AspNetMvc-Version | 4.0 | X-Powered-By | ASP.NET | 请求头信息
Accept | application/json, text/javascript, */*; q=0.01 | Accept-Encoding | gzip, deflate | Accept-Language | zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 | Content-Type | application/json | Host | www.1234.com | Referer | http://www.1234.com | User-Agent | Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:27.0) Gecko/20100101 Firefox/27.0 | X-Requested-With | XMLHttpRequest |
|