/ ASP.NET MVC

Accessing an IIS Express website from another device

IIS Express is great, no need to install IIS and mess around setting up sites it’s there ready for you with your Visual Studio installation. Unfortunately out of the box your IIS Express sites are only accesible from the local machine, fortunately with only a few steps you can easily give external devices access.

For this example I have a web application named Sample.Website configured to run on port 51502 and the IP address of my local machine is 192.168.2.123, you will replace those values with your own name/IP/port combination.

Add a new site binding

First we find the site config in C:\Users[YourName]\Documents\IISExpress\config\applicationhost.config with the name Sample.Website, it should look something like:

<site name="Sample.Website" id="2"> 
  <application path="/" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="/" physicalPath="C:\Users\adam\Documents\Visual Studio 2013\Projects\Sample.Website" /> 
  </application> 
  <bindings> 
    <binding protocol="http" bindingInformation="*:51502:localhost" /> 
  </bindings> 
</site>

Add a new binding below the existing binding to localhost:

<binding protocol="http" bindingInformation="*:51502:192.168.2.123" />

So now the site config should look something like:

<site name="Sample.Website" id="2"> 
  <application path="/" applicationPool="Clr4IntegratedAppPool"> 
    <virtualDirectory path="/" physicalPath="C:\Users\adam\Documents\Visual Studio 2013\Projects\Sample.Website" /> 
  </application> 
  <bindings> 
    <binding protocol="http" bindingInformation="*:51502:localhost" /> 
    <binding protocol="http" bindingInformation="*:51502:192.168.2.123" /> 
  </bindings> 
</site>

Register the URL

Run the following from an administrative command prompt to allow access to the url:

http add urlacl url=http://192.168.2.123:51502/ user=everyone

Open your firewall port

Finally run the following from an administrative command prompt to open your firewall on the necessary port:

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

Browse the site from another device

That’s it you should now be able to access the site via it’s IP/port combination, happy browsing 🙂

If you’re on a domain you could of course also use your machine name instead of IP address.