By default, IIS Express has made it difficult to use custom hostnames when developing locally, as you have had to edit a machine-level file
applicationhost.config. In VS2015, this has been moved into
$(solutionDir)\.vs\config\applicationhost.config which makes it much easier to work against, and to share with other members of your team.
Here are the steps to enabling a custom hostname.
You should have a VS2015 solution containing a web application which opens on IIS Express, on a localhost port (e.g. MyWebApp on localhost:12345)
1 - Edit your applicationhost.config
Open the file
$(solutionDir)\.vs\config\applicationhost.config in a text editor. I like to add it as a Solution Item using "Add Existing Item" in VS.
Find the text that looks something like
<site name="MyWebApp" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="..." /> </application> <bindings> <binding protocol="http" bindingInformation="*:12345:localhost" /> </bindings> </site>
We need to change the
binding element to use the custom hostname. I'm using
mywebapp.127.0.0.1.xip.io as my custom hostname.
xip.io is a dynamic DNS server which points to whatever IP address you embed into the hostname, in this case 127.0.0.1. This stops you having to faff around with local
hosts file entries. Here's the updated element:
<bindings> <binding protocol="http" bindingInformation="*:80:mywebapp.127.0.0.1.xip.io" /> </bindings>
2 - Update the project settings in Visual Studio.
3 - Run the project