How to check wether a domain name exists in asp.net with C#?
-
11-10-2019 - |
Question
Is there a free/open source tool to verify wether a domain exists in c#? I ve a textbox where my user can enter his domain name and list of radio buttons like .com,.net,.in etc... Any suggestion..
Is there any webservice that does it?
EDIT : I need to check only the domain name availability.. Any ideas...
Solution
It's built into the .net Framework:
var server = Dns.Resolve("www.stackoverflow.com");
OTHER TIPS
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"));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow