Home | Contact Us | Download | Support | Purchase | Products

Product List
  "Great products, best support I have ever seen, I highly recommend all products created by Advanced Intellect. Thanks a lot Dave, Advanced Intellect potentially saved us a lots of dollars."
Devin Jaiswal
Bellevue Data Communications, LLC


The following article will describe how to use aspNetPing from Visual Studio .NET using C#. This brief tutorial assumes you have IIS installed locally on your machine, and have downloaded and installed aspNetPing from www.aspNetPing.com . For an updated version of this article, visit www.aspNetPing.com/examples.aspx 


Using Visual Studio .NET (VS.NET ) You will create a single webform (PingMe.aspx) that allows users to ping a host. PingMe.aspx will use aspNetPing to create an ICMP packet and ping a remote host 4 times.

1. Launch Visual Studio .NET

2. From the main menu, select the File | New | Project command.

3. The New Project dialog box appears. Under Project Types, Select Visual C# Projects. Under Templates, select ASP.NET Web Application. In the Location textbox, enter http://localhost/aspNetPingTest


Setting the Reference to aspNetPing.
1. In the Solution Explorer, right-click the project name, aspNetPingTest, and select the Add | Add Existing Item command.

2. The Add Existing Item dialog box appears. Under Files of Type, select All Files(*.*). Navigate to the directory you downloaded aspNetDns.dll too. Double-click the aspNetDns.dll. The Add Existing Item dialog box closes, and the aspNetDns.dll was imported to the root directory of your project.

3. In the Solution Explorer, right-click the project name aspNetPingTest and select Add Reference. The Add Reference dialog box appears. Click the Browse button. The Select Component dialog box appears. Double-click the aspNetDns.dll file. The Select Component dialog box closes. Click OK. The Add Reference dialog box closes, and a reference is set to aspNetPing.

Create a Test Page.
Now that we have a reference set, let's create pingme.aspx to use aspNetPing.

1. In the Solution Explorer, right-click the project name aspNetPingTest, and select Add | Add Webform. The Add New Item dialog box appears. In the Name textbox, enter, pingme.aspx.

2. pingme.aspx loads in the designer window. Select the View | Html Source menu command. The html code of pingme.aspx appears. Between the opening and closing form tags add the following html

<INPUT id=txtHost type=text runat="server" NAME="txtHost"><INPUT type=submit value=Ping ID="Submit1" NAME="Submit1">
<PRE><asp:Literal id=PingResults Runat="server"></asp:Literal></PRE>

 This code will create a html text box, a submit button, and a <asp:literal> tag that we will use for writing out our results.

3. In the Solution Explorer, right-click pingme.aspx, and select View Code.

4. Add the following using statement to the top of the page.

	using aspNetPing;


5. Be sure the following two lines of code to wire up the TextBox and <asp:Literal> are available at the class level.

	protected System.Web.UI.WebControls.Literal PingResults;
	protected System.Web.UI.HtmlControls.HtmlInputText txtHost;

6. To the Page_Load method, add the following code.

private void Page_Load(object sender, System.EventArgs e)
	if( Page.IsPostBack )
		string hostToPing = txtHost.Value;
		// Put user code to initialize the page here
		ReplyPacketCollection reply = IcmpClient.Ping( hostToPing, 4);
		PingResults.Text = reply.ToString();

This code first checks to see if the page was posted.  If the page was posted, the host is pinged the static method IcmpClient.Ping. The results are written to the literal tag by calling Reply.ToString(). ToString() specifically formats the ping results.


Testing The Page
Lets compile and test the page.

1. In the Solution Explorer, right-click the project name, aspNetPingTest, and select Build. The project will be compiled.

2. In the Solution Explorer, right-click pingme.aspx and select View in Browser.

3. Enter an IP or a host (such as www.yahoo.com )the textbox. Click Pingand aspNetPing will ping the host.   You should see similar results to those below:


EchoReply from seq: 1 bytes=32 time=81ms TTL=49
EchoReply from seq: 2 bytes=32 time=90ms TTL=49
EchoReply from seq: 3 bytes=32 time=90ms TTL=49
EchoReply from seq: 4 bytes=32 time=90ms TTL=49

Ping statistics for:
	Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
	Minimum = 81ms, Maximum = 90ms, Average = 87ms

That's all there is to using aspNetPing from Visual Studio .NET. In these few simple steps you were able to create a project, set a reference to aspNetPing, and ping an IP address. For more questions or comments, feel free to write support@advancedIntellect.com

Complete Source Code Listing
The entire source listing can be found here.

The box is not shipped. aspNetPing is a downloadable product.