我正在缩小与twoprior问题有关的潜在问题。HttpWebRequest如何将URL粘贴到地址栏中(功能性)有所不同?
基本上,我有一个URL,当我手动获取它(将其粘贴到浏览器中)时工作得很好,但是当我运行一些代码(使用HttpWebRequest)时会得到不同的结果。
的网址(例如):
http://208.106.250.207:8192/announce?info_hash=-%CA8%C1%C9rDb%ADL%ED%B4%2A%15i%80Z%B8%F%C&peer_id=&port=6881&uploaded=0&downloaded=0&left=0&compact=0&no_peer_id=0&event=started
代码:
String uri = BuildURI(); //Returns the above URL
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
req.Proxy = new WebProxy();
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
... Parse the result (which is an error message from the server claiming the url is incorrect) ...
所以,我怎样才能从给定的URL的服务器得到什么?我显然在这里做错了什么,但不知道是什么。
无论是我的代码修复,还是实际工作的替代方法都可以。我根本就不喜欢HttpWebRequest方法。
这不是[网页开发],它是一个桌面应用程序。 BitTorrent是精确的。 – 2009-07-09 22:46:28