Hi,
In Code i want to validate a domain name.
For example : " DomainName.com".
How can i do that in C#.
I worked on MSDN Solution. (Second Solution).
But "PingCompletedCallback" is not getting executed.
Thanx
Hi,
In Code i want to validate a domain name.
For example : " DomainName.com".
How can i do that in C#.
I worked on MSDN Solution. (Second Solution).
But "PingCompletedCallback" is not getting executed.
Thanx
You could use the Ping class - here's all the info you need on MSDN
I don't think pinging a domain name will tell you anything relevant in a reliable way.
A domain name can be registered but not connected to a server. Ping requests will fail even though the domain is registered.
A server can be fully operational but be configured not to respond to ping requests. Ping requests will fail even if the domain is registered and running on a server.
What do you want to do - find out whether a domain is registered, whether it's a valid domain name, or whether it's a working website / mail server ...?
For the first two, I would recommend using a whois
service.
See for example these C# related questions:
There's a class for that;
MSDN Article on System.Net.NetworkInformation.Ping
Using the System.Net.NetworkInformation.Ping class,
using System.Net.NetworkInformation;
Ping sender = new Ping();
PingReply reply = sender.Send ("www.example.com");
if (reply.Status == IPStatus.Success)
{
Console.WriteLine("Ping successful.");
}
It's untested, but that's the general idea.