This tutorial will show you how to ping a hostname/ip using the .NET System.Net class, ASP.NET 2.0 and C#.NET

The .NET Framework offers a number of types that makes accessing resources on the network easy to use.
To perform a simple ping, we will need to use the System.Net, System.Net.Network.Information, System.Text namespaces.

We’ll put our code in the btnSubmit_Click() event.

When the btnSubmit_Click() event fires it creates a new Ping object. We can then execute the Send method of this object to send a ping to the host specified in our text box. Executing this method also returns a PingReply object which we can use to gather information such as the Address, Roundtrip Time, TTL, and Buffer Size.

The front end .aspx page looks something like this:

The flow for the code behind page is as follows:

Download Source Files