Configuring IIS Express URL to be a domain without a port number

willsullivan 21 Reputation points
2021-05-24T18:28:57.467+00:00

I've got a requirement for my development environment that's causing me heartache with IIS Express.

My company has a suite of websites and lots of developers across multiple teams. To keep everybody consistent, source is designed to where every website has its own separate domain, e.g., productone.example.com, producttwo.example.com, etc.

Unfortunately, it looks like IIS Express outright refuses to accept a bare domain (one without a specified port #). This is forcing me to have to host the website in IIS and perform the dance of the ******* whenever I want to debug (run VS as admin, build, start app pool, locate app pool PID, attach to process, locate PID, yell in frustration).

Is there any way to get IIS Express to run against a domain only? https://producttwo.example.com on port 443?

Developer technologies | Visual Studio | Debugging
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2021-05-24T18:43:19.297+00:00

    There is but I think you are missing the point of IISX. Domain names are useful when you start hosting on the web server that everyone shares. Local development in IISX doesn't need a DNS name because it is local. The port # is required in order to allow you to host multiple sites at the same time. None of this matters to anyone outside of your local development machine. The only place it might remotely appear is if you have configuration entries that are hard coded to particular DNS names. But this is what your environment transforms (.NET Framework) or settings files (.NET Core/5) are for. So ultimately I don't think any of this should be a big deal for local development. You shouldn't need DNS names for IISX in most cases. It is added work for no benefit.

    When you deploy your app to a web server you can definitely use, and should, DNS names. In general you'll configure a separate site for each of your hosted apps. Each site will have a binding that uses the DNS host header to point it to the correct site. Hence you won't need port numbers or virtual paths off the default site on a hosted server. But, again, none of this should matter for local development. You will have different settings between your environments (e.g. connection strings, DNS names, etc) and that should be properly parameterized in your app or via environment variables (.NET Core).

    Can IISX use host names? Yes it can. But to get it to work you have to modify the per-solution IISX configuration file that is stored in a hidden, non-source controlled folder. Within there you can configure IISX to support the equivalent of host names in IIS that map to a specific local host/port setting. However when you use a browser or something to navigate to that DNS then it doesn't know that you are trying to access a local host so it'll try to do DNS lookup anyway. Therefore you also have to update your hosts file to map the desired DNS name to the local IP address (127.0.0.1). Then the networking subsystem will map to the local IP which then triggers a call to IIS. However port information is not supported in the hosts file so you lose that information. You can google for some articles on how to get IISX to (partially) support DNS names.

    In my experience, having to use this on 1 third-party application, it is flaky at best, the URLs may or may not work properly and it adds way more problems then it remotely solves. Personally I wouldn't do it unless I absolutely had to.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.