Accessing the Visual Studio ASP.NET Development Server from iPhone

You Can Take it With You

Syndication

News

UPDATE: See [herefor an updated version of this post addressing Windows 7 issues.

One of the things that makes working with and debugging ASP.NET so easy is the ASP.NET Development server. With the ASP.NET Dev Server you can test and debug your ASP.NET code in Visual Studio by simply pressing <F5>.

As you know, when debugging ASP.NET code on your desktop, the desktop browser accesses your ASP.NET development site using a localhost URL referencing the specific port for the ASP.NET Development Server instance. Something like this…

http://localhost:3804/MyWebSite/Default.aspx

If you have an iPhone or iPod Touch (or Windows Mobile or BlackBerry device) on your local Wi-Fi network, it would seem reasonable that you should be able to access your development site by using the same URL with the localhost part changed to your desktop computer’s IP Address or name. Assuming that the desktop IP Address is 192.169.1.100, the URL would look like this...

http://192.168.1.100:3804/MyWebSite/Default.aspx

Unfortunately, you’ll find that your device’s browser will report that the site cannot be reached.

Interestingly, if you were to enter that same URL into a Windows Mobile emulator or BlackBerry simulator running on your desktop it’ll work just fine. So what’s the problem??

The issue is that for security reasons, the ASP.NET Dev Server will not accept connections issued by other computers.  Your desktop browser and the emulators/simulators are able to access your site because they are processes executing on your local desktop, the same computer on which the ASP.NET Dev Server is running.

So what’s the solution? … Make the ASP.NET Dev Server think that the connection from your device is actually occurring on the local desktop.

This is easily done using any kind of port-forwarding software. This is software running on your desktop that accepts HTTP connections on one port and then forwards everything received on that port to another port.

There are any number of applications that do this sort’a thing. The one I use is a really (really) old tool I’ve used for years from the Microsoft Soap Toolkit 3.0 simply called “Trace Utility”. You can download the toolkit from here. If you already have a networking tool that supports port forwarding, I’d go ahead use that instead.

If you do decide to use the Soap Toolkit Trace Utility one thing you’ll want to remember when installing the toolkit is to only install the “Debugging Utilities”. The rest of the components in the toolkit are used for COM-based Soap development which isn’t relevant to what we’re doing.

In the case of the Soap Toolkit Trace Utility, all you need to do to enable port forwarding is

  • Start the utility
  • Select File | Formatted Trace
    • It will then prompt you for the port to listen on, and the machine and port to forward to.
  • The listen port defaults to 8080 which in most cases you can leave as is.
  • The destination host defaults to localhost which you'll also want to leave as is
  • For the destination port, enter the port number of the ASP.NET Dev server
    • In the above examples, the ASP.NET Dev Server port is 3804.
  • Click OK.

With that, you now have port-forwarding in place. Now on your device, enter the URL using the Trace Utility listen port, 8080, like this.

http://192.168.1.100:8080/MyWebSite/Default.aspx

You’ll find that your iPhone, iPod Touch, Windows Mobile, or BlackBerry device will now be able to access your dev site just fine.

This all works very simply … the device is connecting to the utility and the utility is connecting to the ASP.NET Dev Server. Because the utility is running on your desktop, the ASP.NET Dev Server is happy to accept the connection.

I’ve been using this technique for a number of years (as you can tell by the utility I use) and it continues to work very well. I hope you find it as useful as I have.


Posted Sep 03 2009, 09:32 AM by jim-wilson

Comments

DotNetShoutout wrote Accessing the Visual Studio ASP.NET Development Server from iPhone - Jim Wilson- Pluralsight Blogs
on 09-05-2009 10:42 AM

Thank you for submitting this cool story - Trackback from DotNetShoutout

Nathan Prather wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 09-08-2009 6:46 AM

Thanks a bunch, I will use this technique for testing IE 6 on a virtual machine to connect to the asp.net development web server.

Big time saver!

Denis Richard wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 09-08-2009 6:48 AM

That’s very cool and will hopefully make it possible to access the Visual Studio ASP.NET Development Server from iPhone

neil wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 09-09-2009 4:46 AM

very cool

Globals wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 10-02-2009 10:04 PM

all good things

Nripendra wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 10-22-2009 5:05 AM

Thanks a lot. Saved my lots of time.

Wilson Wu wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 11-17-2009 11:10 PM

Very good.  Thanks.  It works!!

Mahdi wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 11-22-2009 11:53 AM

oh man you did a great job,i enjoyed it alot

Gary Parkin wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 12-03-2009 8:56 AM

Jim, you rock! This works like a charm.

My development machine is Win2000 and IE is broken so I text in FF.

Now I can connect from any machine and see my development environment.

Thank you so much!

~G

desktop computers wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 07-19-2010 12:27 AM

You did a great job for all ASP developers. Keep posting these type of posts. Although ASP development was coming to me veyr hard but now it is working very smooth.

desktop computers wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 07-19-2010 12:28 AM

You did a great job for all ASP developers. Keep posting these type of posts. Although ASP development was coming to me very hard but now it is working very smooth.

julian wrote re: Accessing the Visual Studio ASP.NET Development Server from iPhone
on 08-05-2010 3:53 PM

Excelente, muchas gracias.

You Can Take it With You wrote iPhone Accessing the Visual Studio ASP.NET Development Server - Windows 7 Update
on 08-19-2010 8:10 AM

About a year ago (tomorrow is 50 weeks to the day) I wrote a post Accessing the Visual Studio ASP.NET

Add a Comment

(required)  
(optional)
(required)  
Remember Me?