我想用TOR代理我的asp.net应用程序发送HttpWebRequest和调用webresponse.GetResponse()方法时,我收到此错误信息:
服务器犯了违反协议。 第= ResponseStatusLine
我试图寻找在网络上的解决方案,我发现这个错误3级主要的解决方案:
添加到Web.config中。
<system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true"/> </settings> </system.net>`
添加行:
webRequest.ProtocolVersion = HttpVersion.Version10;
该代码。- 添加行
request.ServicePoint.Expect100Continue = false;
该代码。
所列出的解决方案中的每一个并没有改变有关错误消息的事情。
这里的请求代码:
WebRequest.DefaultWebProxy = new WebRequest("127.0.0.1:9051");
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.CookieContainer = new CookieContainer();
webRequest.ProtocolVersion = HttpVersion.Version10;
webRequest.KeepAlive = false;
webRequest.Method = "GET";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
webRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19";
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
string html = streamReader.ReadToEnd();
webResponse.Close();
return html;
谁能帮我找到了一个解决方案?