If using IIS Express (the default for debugging web applications in Visual Studio), you can use domains other than localhost
but its not particularly intuitive.
- First, get the port number your Web application is running on (either copy it from the URL or grab it from the project settings, debug tab).
- Navigate to
%UserProfile%\Documents\IISExpress\config\
and openapplicationhost.config
(Full path:%UserProfile%\Documents\IISExpress\config\applicationhost.config
) - Find the reference to the port number (49483 in my case). It might look something like this:
- Now all that remains to do is add another binding to the section:
You can also set it to accept all hosts on that port by adding the following (note empty string, not wildcard *
):
You will have to have set up this host to point to 127.0.0.1
in your hosts file. Or, my favourite method is to use a domain I own and point *.sub.mydomain
to 127.0.0.1
. Hosts file doesn’t support wildcards (*
) but DNS does! This means I can easily set up projecta.sub.mydomain
and projectb.sub.mydomain
without having to add new lines to my hosts file (so long as I have an internet connection)!
One thought on “Using a Domain other than localhost with IIS Express”