日期:2014-05-18  浏览次数:20902 次

远程服务器返回错误:501
C# code
   System.Net.ServicePointManager.Expect100Continue = false;
                WebClient webClient = new WebClient();
                 webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                webClient.Headers.Add("Content-Type", "charset=UTF-8");
                webClient.Headers.Add(HttpRequestHeader.KeepAlive, "false");
                webClient.Headers.Add("Cache-Control", "no-cache");
                webClient.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
                byte[] postData = Encoding.UTF8.GetBytes(postString);
                byte[] responseData = webClient.UploadData("http://xxx.com/a.aspx", "POST", postData);
                string srcString = Encoding.Default.GetString(responseData);

用webclient访问网页时,在一些电脑上会出现错误:远程服务器返回错误:501(未实现),而一些电脑上却完全正常,求解决办法,谢谢!

------解决方案--------------------
501 未执行 — 服务器不支持请求的工具。
------解决方案--------------------
webClient.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
涉及到工具的时候这行要注意。

反正我不懂。
------解决方案--------------------
楼上不错。

给HttpWebRequest指定一个UserAgent
------解决方案--------------------
同求答案