Reputation: 35266
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...
Upvotes: 2
Views: 3938
Reputation: 346
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"));
Upvotes: 1
Reputation: 24
It's built into the .net Framework:
var server = Dns.Resolve("www.stackoverflow.com");
Upvotes: 0