Skip Navigation LinksHome > Categories > Code from a Category

Pinging with options using ASP.NET 2.0 and C# .NET

User Name: codelecturer
Name: Mike Chauhan
Contact Me:
Home Page:
6 years of total IT experience including programming, application development, System Maintenance . 3 years of Experienced and expertise in .Net Framework VB, Visual Basic.Net, ASP.Net 2.0, 3.5 and AD... [More]
Viewed Times: 1742
Add Date: 11/18/2012
This tutorial will show you how to include ping options when pinging 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 display an external webpage we will need to use the System.IO, System.Net, and 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. In addition, we define ping options using the PingOptions class.

The front end .aspx page looks something like this:

The flow for the code behind page is as follows:

Happy Programming!!!

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.