Click here to Skip to main content
11,806,575 members (40,302 online)
Click here to Skip to main content

Creating a global Whois class

, 6 Dec 2003 60.9K 1.2K 33
Rate this:
Please Sign up or sign in to vote.
Lookup a domain name for any tld (top level domain)


I realise there is already a Whois example for C# on codeproject, in the form of an snippet. The class I've posted here encapsulates a little more functionality than that example, and is taken from a Perl script i wrote a few years back.


The Whois class has one main method, Lookup(domain). From this, the class works out what whois server should be used for the domain lookup. This is done by a trick taken from the Perl script, the service is provided by, hosted by CenterGate. From performing a dns lookup on the domain name's tld (e.g. .com for, attached to, you're provided with the address of the whois server for that domain, if one exists.

I've built into the class, the ability to provide your own whois server, via the WhoisServer property. I've also added checks for a few domain names which don't provide free whois servers, and the .tk domain which does, but isn't on the service.

The class performs the lookup, and raises an event, LookupComplete when it's finished, passing a WhoisEventArgs class with it, which provides the results of the lookup, and the whois server that was used.

To check whether a domain is taken or not, is up to you - you'll have to parse the string provided in the WhoisInfo property of the WhoisEventArgs class.

The example project is a small windows forms application, to demonstrate how to use the class. The class doesn't cater for non-resolving whois servers at present, it could perhaps do with a few more lines of error trapping in this area.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United Kingdom United Kingdom
London based C# programmer.

I maintain my own pet C# site in my spare time.

You may also be interested in...

Comments and Discussions

QuestionHow to fix occational timeouts Pin
thorssig5-Oct-13 8:52
memberthorssig5-Oct-13 8:52 
Questionvery bad code | code kuy kuy Pin
Suchart_mart6-Feb-12 22:30
memberSuchart_mart6-Feb-12 22:30 
GeneralSocket Exception Unhandled - No such host known Pin
Sniper16718-Jul-07 18:36
memberSniper16718-Jul-07 18:36 
GeneralRe: Socket Exception Unhandled - No such host known Pin
smallguy7823-Jul-07 0:10
membersmallguy7823-Jul-07 0:10 
GeneralWhois class implementation Pin
Syst3m Crash3r 48030-May-06 6:27
memberSyst3m Crash3r 48030-May-06 6:27 
Hi, I'm a young programmer and I am developing a network tool, named N3tShark. I need to include the class in my open source project ( ), so I ask you the permission.

I hope in a "freeware" response... Wink | ;-)

GeneralRe: Whois class implementation Pin
smallguy7814-Nov-06 0:16
membersmallguy7814-Nov-06 0:16 
QuestionC# IPHostEntry Cache??? Pin
kvnsdr20-Aug-04 17:56
memberkvnsdr20-Aug-04 17:56 
GeneralWhois Server Pin
youssef elmansouri8-Dec-03 23:25
memberyoussef elmansouri8-Dec-03 23:25 
GeneralRe: Whois Server Pin
smallguy789-Dec-03 7:18
membersmallguy789-Dec-03 7:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151002.1 | Last Updated 7 Dec 2003
Article Copyright 2003 by yetanotherchris
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid