Remote Connections to Visual Studio’s Web Server

The integrated development web server in Visual Studio is a handy tool. Since its introduction developers of ASP.NET web applications and web services have been able to build and test their code locally, without having to take the post-build step of publishing to an IIS server first. A nice tool, but a slightly crippled one. Presumably because Microsoft did not want people to use the full-featured server to deploy production applications it only accepts connections from localhost. In my current work on an iOS app I wanted to issue http requests from an iPod Touch over a wifi network, and send them to a REST web service running under Visual Studio 2010 on my development machine. Ordinarily you can’ t do this. You’d have to install the service code in a local instance of IIS and set VS up to step through it there.

If you Google around on this problem you’ll find a number of solutions. The actual code inside the server that rejects remote connections is just a couple of lines and not at all complicated. For this reason some people have suggested using ildasm to disassemble the web server assembly and comment out the relevant test. But there is a much easier and less intrusive way to get around this problem, and it just takes a couple of minutes to set up.

First, find and download a port forwarding utility for Windows. I use Portforward by Trent Waddington, because it is small, requires no installation, and is easy to use. His download link is to an exe file so I won’t post it here, but you can find it midway down this page. What you’re going to do with the port forwarding utility is make Visual Studio’s web server think your connection is coming from localhost, when in fact it is coming from a remote device.

Once you have the port forwarding utility, open up your VS application, and get into the project properties dialog. Click the ‘web’ tab and look for the ‘Servers’ section of the property page. The radio button next to ‘Use Visual Studio development server’ should be checked. Below it check the radio button next to ‘specific port’, and then type a port number into the edit box on the right. I usually use 35000. Save the project properties. Build and run. Your web application is now running on the dev server and listening for http connections on whatever port you chose.

Now start the port forwarding utility and set up a forwarding rule. You do this in various ways in different tools, but in Portforward you click “Redirections” and then “Add” and it pops a little dialog. Let’s say that the machine you’re running the web app on has an IP of, and your client is going to try to connect to port 8080. Set up a rule that forwards to localhost:35000 and you’re good to go. Now when your client connects the connection will be redirected to the development web server on localhost, which will make it happy, and make you happy at the same time.

One thought on “Remote Connections to Visual Studio’s Web Server

Leave a Reply

Your email address will not be published. Required fields are marked *