Getting IIS Express to listen on your machine’s hostname (or hostnames) and not just localhost can be pretty handy. From a high-level there are 3 basic steps:
- Change IIS Express Configuration for the Visual Studio Solution
- Tell http.sys to respond to requests from everyone
- Open the local firewall to incoming port 443
Change IIS Express Configuration for the Visual Studio Solution
Open the solution-specific configuration file. If you’re using Visual Studio 2015 then it can be found in the following folder:
If you can’t see the .vs folder then make sure you can view hidden files in Explorer – (.vs is a hidden folder).
Look for the lines with the element <binding> that are specific to the site / project you are editing. Change the <binding> element entries to be:
<binding protocol="http" bindingInformation=":52646:" /> <binding protocol="https" bindingInformation=":44394:" /> <binding protocol="https" bindingInformation=":443:" />
(The primary change is the removal of the ‘localhost’ or ‘*’ in the part of bindingInformation that specifies the hostname of the listening endpoint.)
Tell http.sys to respond to requests from everyone
This step is a simple netsh command. Make sure to change the port according to the settings in your project, I’m using 443 as an example.
netsh http add urlacl url=https://*:443/ user=everyone
If you get an error about the file already existing then you may want to run the following and then re-rerun the netsh http add command:
netsh http delete urlacl url=https://*:443/
Open the local firewall to incoming port 443
Again, a simple netsh command.
netsh advfirewall firewall add rule name="Open Port 443" dir=in action=allow protocol=TCP localport=443
After that you should be good to go. Open a browser and navigate to your site using your hostname and port number.