Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends,
i want to add domain name finding utility in my web site . is any web service is available for asp.net ?
Posted
Comments
Manas Bhardwaj 21-Jun-12 10:08am    
Not clear!

1 solution

Following is a simple console program which checks whether if the domain name exists or not.

You can convert it into a webservice if you wish to.

C#
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;

namespace DemoDNS
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter a domain for lookup.");
            var domainName = Console.ReadLine();
            try
            {
                var ipAddress = Dns.GetHostEntry(domainName);
                if (ipAddress.AddressList.Count() > 0)
                {
                    Console.WriteLine("The domain already exists!");
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
 
Share this answer
 
Comments
Pankaj Nikam 21-Jun-12 10:26am    
This solution is given as far as I understand the need of yours. If not, please reply me on this comment, I would love to help you. Thanks.
Abhishek Pant 24-Nov-13 2:46am    
+5
Worked for me too!! searching this from 2 days
Pankaj Nikam 24-Nov-13 10:17am    
Glad to be of help :)
Thanks for the upvote :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900