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

Product List
  "2.5 has some rocking new features...!"


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


Using Visual Studio .NET (VS.NET ) You will create a single webform (TraceMe.aspx) that allows users to trace a route to a host. TraceMe.aspx will use aspNetTraceRoute to create an ICMP packet.

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/aspNetTraceRouteTest


Setting the Reference to aspNetTraceRoute.

1. In the Solution Explorer, right-click the project name, aspNetTraceRouteTest, 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 aspNetDns.dll. 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 aspNetTraceRouteTest 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 aspNetTraceRoute.

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

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

2. TraceMe.aspx loads in the designer window. Select the View | Html Source menu command. The html code of TraceMe.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=Trace ID="Submit1" NAME="Submit1"> 
<br> <PRE><asp:Literal id=TraceResults  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 TraceMe.aspx, and select View Code.

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

	using aspNetTraceRoute;


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 TraceResults;
	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 )
		TraceRouteReplyCollection results = TraceRouteClient.Trace(txtHost.Value, 30, true );
		TraceResults.Text = results.ToString();

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


Testing The Page
Lets compile and test the page.

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

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

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


0 40ms 43ms 50ms rt3-sc-psci.psci.net []
1 40ms 47ms 51ms rt3-sc-psci.psci.net []
2 40ms 46ms 50ms rt1-sc-psci.psci.net []
3 50ms 56ms 60ms Serial0-1-0.GW1.IND1.ALTER.NET []
4 50ms 56ms 60ms 121.at-2-1-0.XR2.CHI4.ALTER.NET []
5 60ms 63ms 70ms 194.at-1-0-0.XR2.CHI2.ALTER.NET []
6 60ms 60ms 60ms 0.so-2-1-0.XL2.CHI2.ALTER.NET []
7 60ms 60ms 61ms 0.so-7-1-0.BR6.CHI2.ALTER.NET []
8 60ms 60ms 60ms bpr1-so-6-0-0.ChicagoEquinix.cw.net []
9 60ms 60ms 61ms dcr2-so-4-3-0.Chicago.cw.net []
10 80ms 86ms 100ms dcr2-loopback.Washington.cw.net []
11 80ms 80ms 80ms bhr1-pos-10-0.Sterling1dc2.cw.net []
12 71ms 77ms 80ms csr12-ve241.Sterling2dc3.cw.net []
13 80ms 80ms 80ms
14 80ms 83ms 90ms vl33.bas2-m.dcn.yahoo.com []
15 80ms 80ms 81ms w19.www.dcn.yahoo.com []

That's all there is to using aspNetTraceRoute from Visual Studio .NET. In these few simple steps you were able to create a project, set a reference to aspNetTraceRoute, and trace a route to a remote host. 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. aspNetTraceRoute is a downloadable product.