我正在尝试使用tor代理发送httpwebrequest,与我的asp.net应用程序一起,并且在调用webresponse.GetResponse()方法时收到此错误消息:
有人能帮我找到解决这个问题的方法吗?
我已经尝试在网上寻找解决方案,并找到了3个主要的解决方案:服务器违反了协议。 Section=ResponseStatusLine
Add to Web.config.
<system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true"/> </settings> </system.net>`
Add the line:
webRequest.ProtocolVersion = HttpVersion.Version10;
to the code.- Add the line
request.ServicePoint.Expect100Continue = false;
to the code.
列出的解决方案都无法改变错误信息。
这是请求代码:
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;
有人能帮我找到解决这个问题的方法吗?