如何检查域可用性。 [英] How to check domain availability.
问题描述
最近,我被分配了一个任务来创建一个简单的网页,这将有助于任何人知道他/她想要注册的域名的可用性。
我在使用asp.net的.net平台上。对于此任务,我想使用 System.Net 命名空间,并在 WebResponse和WebRequest 类的帮助下,我可以知道注册了哪个域。但在那里我可以了解一下只运行网站。
但是,如果有人注册了他/她的域名并且还没有托管任何网站的话。使用这种方法无法追踪。
我正在寻找您宝贵的指导或建议或执行此任务的任何API。
谢谢。
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.
推荐答案
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:)
这篇关于如何检查域可用性。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!