如何使用C#检查ASP.NET中存在Wether域名?
-
11-10-2019 - |
题
是否有一个免费/开源工具来验证C#中是否存在域?我有一个文本框,我的用户可以在其中输入他的域名和广播按钮的列表,例如.com,.net,.in等...任何建议..
有没有网站服务?
编辑 :我只需要检查域名可用性..任何想法...
解决方案
它内置在.NET框架中:
var server = Dns.Resolve("www.stackoverflow.com");
其他提示
public bool isDomainExist(string address)
{
System.Net.WebRequest request = System.Net.WebRequest.Create(address);
request.Method = "HEAD";
try
{
var r = request.GetResponse();
return true;
}
catch (Exception ex)
{
return false;
}
}
console.writeline(isDomainExist("https://stackoverflow.com"));
不隶属于 StackOverflow