How do I clear System.Net client DNS cache?

前端 未结 4 1733
梦毁少年i
梦毁少年i 2020-12-03 04:26

I\'m using the .NET WebRequest while changing my HOSTS file. I\'m observing that System.Net doesn\'t honor those changes - how can I make it do so?

I have a number o

4条回答
  •  萌比男神i
    2020-12-03 05:15

    If you want to keep the DnsRefreshTimeout > 0 then you can update the cache by making a call to:

    System.Net.Dns.GetHostEntry("example.com");
    

提交回复
热议问题