启用多个网络适配器时 HttpWebRequest 超时
在我的 Win7 PC 上,我有几个用于 VMWare 服务器的虚拟网络适配器。 当我启用这些适配器时,我的 HttpWebRequest 超时。我真的应该告诉它要绑定到哪个适配器吗?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url.AbsoluteUri + "etc.txt");
request.Timeout = 2000;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
return reader.ReadToEnd();
}
}
更新
我猜这是一个常见问题。有人有处理这个问题的标准方法吗?我无法真正提示用户界面,因为他们不是技术人员。 Rohit 的回答是展示如何设置 ServicePoint 的良好开端。
On my Win7 PC I have a couple of virtual network adaptors that are used for VMWare server.
My HttpWebRequest times out when I have these adaptors enabled. Should I really have to tell it which adaptor to bind to?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url.AbsoluteUri + "etc.txt");
request.Timeout = 2000;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
return reader.ReadToEnd();
}
}
UPDATE
I'm guessing this is a common issue. Does anybody have a standard way to handle this? I cant really prompt the user for the interface as they are non tech. Rohit's answer is good start at showing how to set the ServicePoint.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Tim,如果您看到超时,那是因为您的新适配器具有 URL 的路由,但它们未到达目的地。
您可以将其用作
...
请参阅 http://www.netbrick.net/blog/PermaLink,guid,b9c255d9-74b4-45ab-8fd0-c9a04784655a.aspx 了解更多详细信息。
Tim, If you are seeing timeout it is because your new adapters have route for the URL and they are not reaching the destination.
You can use it as
and...
See http://www.netbrick.net/blog/PermaLink,guid,b9c255d9-74b4-45ab-8fd0-c9a04784655a.aspx for more details.
以下是罗希茨的回答。这在尝试所有适配器时效果好吗?
Following on from Rohits answer. Would this work well at trying all the adaptors?