HttpWebRequest NameResolutionFailure exception in .NET (with Mono on Ubuntu)

前端 未结 5 1393
我寻月下人不归
我寻月下人不归 2021-01-01 20:14

I have a .NET program running on Ubuntu via Mono 2.10

The program downloads a webpage via an HttpWebRequest every minute or so which works fine most of the time:

5条回答
  •  既然无缘
    2021-01-01 20:35

    You can solve it by translating the host name to ip and add the host name to Headers collection or to Host property.

    If your url is http://example.com/uri. Resolve the host yourself. Suppose its 1.2.3.4. It'll be http://1.2.3.4/uri. Now add Host: example.com header to your request. I think it can be done by setting HttpWebRequest.Host property.

提交回复
热议问题