From time to time, I find myself needing to connect to a debugging VS website from another machine. Maybe it’s for a demo, maybe for an app, maybe it’s cause I’m running VMWare Fusion & want to debug in Safari.
Back in the Casinni days of VS2008, there was this single line of code in Casinni that rejected outside connections. If you had the stomache for some messy hacking, it was possible to remove this check.
These days, support for outside connections is a bit closer to being practical, yet it’s a mirror maze of steps that you have to piece together based on error messages. Well not anymore. These intructions show you how to take a normal VS2010 website & make it accessible from another computer on your network.
Step 1) Make Sure Your Site Works
When I debug on my website called “TestWeb2”, the url is: http://localhost:52214 & it is working fine.
My computer name is jwrightdesktop. You can find yours by typing ‘hostname’ into the command line.
The goal is to go to another computer on my network and access this webpage at http://jwrightdesktop:52214
Step 2) Use IIS Express
- Right-click your web project in VS2010
- Click on the ‘Web’ tab
- Click “Use Local IIS Web Server”
- Click “Use IIS Express”
Run your website again – nothing should have changed except that you’re on IIS express now.
Step 3) Firewall Exception
This wasn’t a problem for me because my firewall wasn’t blocking it. (our firewall is managed from a different area)
Your firewall likely IS blocking outside connections, so checkout this post for tips on opening it up:
http://superuser.com/questions/254558/allowing-remote-connection-in-iis-on-windows-7
Step 4) Bindings
As it stands, IIS knows it should respond to ‘localhost:52214’. You need to tell it that ‘jwrightdesktop:52214’ is ok too.
Open up your applicationhost.config file found in a directory like: C:UsersjwrightDocumentsIISExpressconfig
Find the bindings for your website. Mine look like this:
<site name="TestWeb2.Web" id="8">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="W:TestWeb2TestWeb2.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:52214:localhost" />
</bindings>
</site>
Just below the first binding, add a line like this:
<binding protocol="http" bindingInformation="*:52214:jwrightdesktop" />
Step 5) Run VS2010 as an Admin
Re-run the site. It should probably be working now. If it’s not, then you might need to be running VS2010 as an admin. For me, that means right-clicking the VS icon and clicking ‘Run as Administrator’.
If you click ‘properties’ instead of ‘Run as Administrator’ then under the ‘Compatibility’ tab you can choose to always run this program as admin.
Other Thoughts
You can do the same thing using your ip address instead.
Here are some of the links I found helpful:
- Bindings: http://stackoverflow.com/questions/5442551/iisexpress-returns-a-503-error-from-remote-machines
- Firewall: http://superuser.com/questions/254558/allowing-remote-connection-in-iis-on-windows-7
- Troubleshooting: http://haacked.com/archive/2007/05/18/service-unavailable-errors-in-iis-7-are-killing-me.aspx
- Troubleshooting: http://stackoverflow.com/questions/220274/remote-machines-cannot-connect-to-visual-studio-web-server