Posted on

Accessing an IISExpress site from another device

You may need to access your developing site with Visual Studio from another device, for example if you want to test if the site is really responsive. You just need to make some changes.

When you open your site by visual studio, the address displayed is

http://localhost:port_number

, where port_number is the port number assigned to the project by Visual studio / IISExpress.

In your project directory you find the .vs directory. Open the file

your_project_folder\.vs\config\applicationhost.config

Here is the bindings tag. In the example you see a specific port number but you have yours.

<bindings>
 <binding protocol="http" bindingInformation="*:60132:localhost" />
</bindings>

Add a line with the ip of your computer. You can add as many as you want.

<bindings>
 <binding protocol="http" bindingInformation="*:60132:localhost" />
<binding protocol="http" bindingInformation="*:60132:192.168.1.142" />
 </bindings>

Open a dos prompt with Administrator privileges and type the command:

netsh http add urlacl url=http://192.168.1.142:60132/ user=everyone

At this point you have to create a firewall rule for your port. From the prompt prompt, launch the command:

netsh advfirewall firewall add rule name="IISExpress_website1" dir=in protocol=tcp localport=60132 profile=private remoteip=localsubnet action=allow

Now you can see the IISExpress website from any networked device using

http://192.168.1.142:60132/

Unfortunately, with this operation you’ll no more control the site using http://localhost:60132 because you need administrator privilege to use the port 60132. So you have two possibilities : first open Visual Studio with Administrator privileges; second, delete this acl:

netsh http delete urlacl url=http://192.168.1.142:60132/