Wouldn’t it be nice if you could debug a web project in Visual Studio from an external device, like a mobile app or another computer? While it is is not possible for Visual Studio’s built-in development web server to accept any requests other than those addressed to localhost, IIS Express integrates with Visual Studio and with a bit of configuration allows externally originated requests. Here’s how to do it:

  1. Download and install IIS Express.
  2. Start Visual Studio and load your web project. In Solution Explorer, right-click the web project, select Use IIS Express… and confirm the prompt to create a new site in IIS Express.
  3. Note: You can also change this setting from your project’s Web property page, switching between web servers as necessary.
  4. Open the IIS Express application host configuration file located by default at C:\Users\MyUserName\Documents\IISExpress\configapplicationhost.config.
  5. Search for the name of your project in the configuration file. You should find it in the name attribute of a site element within the sites section of system.ApplicationHost. Inside the site element’s bindings section, you should see a binding element whose bindingInformation attribute references the standard localhost address (prefixed by the port configured in your project).
  6. Copy this binding element line and paste it immediately following the original one, and change localhost to your machine’s IP address. This way, you can access the site with either address.

    site name=”MyWebProject” id=”10″

    application path=”/” applicationpool=”Clr4IntegratedAppPool”

    virtualdirectory path=”/” physicalpath=”C:DevMyWebProject”

    application

    bindings

    binding protocol=”http” bindinginformation=”*:2404:localhost”

    binding protocol=”http” bindinginformation=”*:2404:192.168.1.100″

    bindings

    site

  7. Depending on your machine’s configuration, after saving the above changes, you may now be able to access the site (when started in Visual Studio) from an external device or machine via your machine’s IP address. If not, from an administrator command prompt, substituting your machine’s IP address and port, execute the following command to allow incoming HTTP connections to the URL.

    netsh http add urlacl url=http://192.168.1.100:2404/ user=everyone

  8. You may also need to open the port in your firewall. For Windows Firewall, execute this command:

    netsh advfirewall firewall add rule name=”IISExpressWeb” dir=in protocol=tcp localport=2404 profile=private remoteip=localsubnet action=allow

You should now be able to access your debuggable site from extenal devices!