Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Recently, I have been assigned a task to create a simple web page what will help anybody to know the availability of the domain name that he/she wants to register.

I am on a .net platform using asp.net. For this task,I thought to use System.Net namespace and with the help of WebResponse and WebRequest classes I can come to know which domain is registered. But there I can come to know about only running website.

But what, if someone has registered his/er domain and not host any website yet. That could not be trace using this method.

I am looking for your valuable guidance or suggestions or any API that performs this task.



Thanks.
Posted

1 solution

C#
public static string GetSubDomainID()
       {
           string domainID = HttpContext.Current.Request.Url.Host;
           if (domainID.Contains("/"))
               domainID = domainID.Substring(0, domainID.IndexOf("/"));
           if (domainID.ToLower().StartsWith("www."))//ignore www subdomain
               domainID = domainID.Substring(4);
           if (domainID.Contains("."))//Remove the last part i.e. organization e.g. .com / .net
               domainID = domainID.Substring(0, domainID.LastIndexOf("."));
           if (domainID.Contains("."))//Remove the second last part i.e. primary domain e.g. logisys
               domainID = domainID.Substring(0, domainID.LastIndexOf("."));
           if (domainID.Contains("."))//Get the first part
               domainID = domainID.Substring(0, domainID.IndexOf("."));
           return domainID;
       }


try this coding to check domain availability ....

Happy coding:)
 
Share this answer
 
Comments
Manish Kumar Namdev 3-Dec-12 23:35pm    
@Deenu India : The code you give is ok but this is not what I'm looking.
I am looking that How can I come to know if a domain is registered as gTLD or ccTLD. I am looking to register mine one. Is there any API for that?

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