Skip to content

Instantly share code, notes, and snippets.

@vkbandi
Last active September 17, 2015 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkbandi/49f08f55c02fad0c0244 to your computer and use it in GitHub Desktop.
Save vkbandi/49f08f55c02fad0c0244 to your computer and use it in GitHub Desktop.
A simple C# class for demonstrating the use of whois to check the availability of a domain name - code snippet for coderbuddy.wordpress.com
public class DomainSearch
{
/// <summary>
/// Check whether a given domain name is available or not
/// </summary>
/// <param name="domainName">domain name to be verified</param>
/// <returns></returns>
public static bool IsDomainNameAvailable(string domainName)
{
string whoisData = Whois.Lookup(domainName);
string[] ws = whoisData.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
return ws[7].Contains("No match for domain \"" + domainName.ToUpper() + "\".");
}
}
@vkbandi
Copy link
Author

vkbandi commented Sep 17, 2015

This code uses the Whois.cs code snippet. you can find more info about this code on my blog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment