Best way to determine if a domain name would be a valid in a “hosts” file?

前端 未结 2 530
时光说笑
时光说笑 2020-12-16 15:33

The Windows Hosts file allows you to associate an IP to a host name that has far greater freedom than a normal Internet domain name. I\'d like to create a function that dete

2条回答
  •  眼角桃花
    2020-12-16 15:58

    These methods are not reliable as you get some response even if the domain name is fake like "fasdfasdfasd.com".

    The best way is to send a WebResponse and wait for the response from the domain. Here is the complete code and explanations of this process (long code snippet so not copy-pasting here).

    http://www.dotnetfunda.com/articles/show/1072/validating-domain-name-in-aspnet

    Thanks

提交回复
热议问题