Visual Studio 2017 with IIS Express and custom domains
This has been driving me nuts for months and I really need to get it sorted so this is a cry for help. No matter what I try, in VS2017 I can no longer use custom domains to debug a multi-site install. I used to have it working fine with the 12-14 domains I need to test locally but that has not been the case for some time now.
I am using local IIS Express Config located in my solutions .vs\config\applicationhost.config file. The config looks as follows:
I don't have a problem running my application, it runs fine but only on the localhost hostname. Unfortunately, that link provided no suitable solution but thanks anyway.
Feel free to shoot me on this one, but my understanding is the localhost loopback address in windows only listens on port 80. Additionally there is no ability to specify a port either in the HOSTS file or anywhere else for that matter.
So the way to configure it is to always specify port 80 and 443 in your application hosts file, for example...
It's the way I have it working, you can also register a self signed certificate for use on the domain which works OK in all browsers except chrome due to it jettisoning support for self signed certs.
Its not the host file that determines the port used or what IIS is listening on. http denotes port 80 and https denotes port 443 but these can be overridden by putting adding the port number at the end of a URI such as http://localhost:80808. So this now is looking at the machine that localhost maps to i.e. IP 127.0.0.1 which is usually the machine you are on but is looking at port 80808.
Not disputing that, but Simon is trying to map domains to localhost so youre stuck with the HOSTS file / IIS Express combo which only works on port 80/443.
Thanks for your post, I'm still struggling to see how that can work given that my project (like all VS web projects) will use a randomly assigned port number in IISExpress or you would just face collisions each time you run another project.
Can I confirm that you ARE using IIS Express and not a local IIS instance?
you can also register a self-signed certificate for use on the domain which works OK in all browsers except chrome due to it jettisoning support for self-signed certs.
I don't really need https support locally at the moment - it has never been required in my local environment for this project before now so I will try and avoid any additional complications with this element.
Unfortunately, as in the past, this has sucked up too much valuable time for me and I'm still no further forward so will have to sideline it again for the time being.
IIS Express doesn't just work on ports 80/443, you can start it and have it listen on your chosen available port. I actually have windows context menu shortcut to run any chosen folder in IIS Express using a random port number, you simply pass the /port: parameter to the IIS Express executable when you start it up or you can use a custom config file as is the case with Visual Studio these days.
Are you sure you are not referring to your local IIS instance?
Yes you're right! But I have had similar issues as you when trying to bind a dummy DNS, hence why I ended up sticking with 80/443.
I pulled up an old project where I was using my own domains and it does work as explained on 80/443. One of the cool things about using the default ports is you don't have to append anything and it looks like the real thing in a browser. Also, to my surprise my self signed cert was working again in Chrome! Bonus!
For an in-depth explanation for Studio 2015 onwards which should help you fix it on custom ports go here...
Thanks Martin, I am not using my local IIS instance, I prefer the [previously] low friction IIS Express approach. Thanks for the link but trust me, I have spent countless hours going through and trying the advice in hundreds of posts like that (and including that one). It does not provide a solution to my problem.
Having just quickly checked I also have the same issue in local IIS so now wondering if it is related somehow to firewall/anti-virus. I will check again when I have some available time.
I didn't assume that you were, I don't even have IIS installed on my dev machine any more. I took the same route with SQL and just run localDB. Save's on start-up time, resources and generally easier to manage.
The url mostly covers IIS Express from what I can tell.
Visual Studio 2017 with IIS Express and custom domains
This has been driving me nuts for months and I really need to get it sorted so this is a cry for help. No matter what I try, in VS2017 I can no longer use custom domains to debug a multi-site install. I used to have it working fine with the 12-14 domains I need to test locally but that has not been the case for some time now.
I am using local IIS Express Config located in my solutions
.vs\config\applicationhost.config
file. The config looks as follows:I have added the url reservation as follows:
I have an entry in my host file as follows:
No matter what I try Chrome simply reports
ERR_CONNECTION_REFUSED
Anyone else had any success with this?
Thanks, Simon
My gut feeling is you are experiencing an issue because you are not set up for HTTPS within your project setup.
Can you follow the steps in this StackOverflow answer, paying particular attention to step 5, please?
https://stackoverflow.com/a/48219532
Afterwards, you should change the reserved URL with the new port like so (not forgetting HTTPS)
Hi Anthony,
I don't have a problem running my application, it runs fine but only on the localhost hostname. Unfortunately, that link provided no suitable solution but thanks anyway.
Simon
Hi Simon
Feel free to shoot me on this one, but my understanding is the localhost loopback address in windows only listens on port 80. Additionally there is no ability to specify a port either in the HOSTS file or anywhere else for that matter.
So the way to configure it is to always specify port 80 and 443 in your application hosts file, for example...
and in the HOSTS file
It's the way I have it working, you can also register a self signed certificate for use on the domain which works OK in all browsers except chrome due to it jettisoning support for self signed certs.
Kind regards Martin
Hi Martin
Its not the host file that determines the port used or what IIS is listening on. http denotes port 80 and https denotes port 443 but these can be overridden by putting adding the port number at the end of a URI such as http://localhost:80808. So this now is looking at the machine that localhost maps to i.e. IP 127.0.0.1 which is usually the machine you are on but is looking at port 80808.
Hi Barry
Not disputing that, but Simon is trying to map domains to localhost so youre stuck with the HOSTS file / IIS Express combo which only works on port 80/443.
Hi Martin,
Thanks for your post, I'm still struggling to see how that can work given that my project (like all VS web projects) will use a randomly assigned port number in IISExpress or you would just face collisions each time you run another project.
Can I confirm that you ARE using IIS Express and not a local IIS instance?
I don't really need https support locally at the moment - it has never been required in my local environment for this project before now so I will try and avoid any additional complications with this element.
Unfortunately, as in the past, this has sucked up too much valuable time for me and I'm still no further forward so will have to sideline it again for the time being.
Cheers, Simon
Hi Martin,
IIS Express doesn't just work on ports 80/443, you can start it and have it listen on your chosen available port. I actually have windows context menu shortcut to run any chosen folder in IIS Express using a random port number, you simply pass the
/port:
parameter to the IIS Express executable when you start it up or you can use a custom config file as is the case with Visual Studio these days.Are you sure you are not referring to your local IIS instance?
Hi Simon
Yes you're right! But I have had similar issues as you when trying to bind a dummy DNS, hence why I ended up sticking with 80/443.
I pulled up an old project where I was using my own domains and it does work as explained on 80/443. One of the cool things about using the default ports is you don't have to append anything and it looks like the real thing in a browser. Also, to my surprise my self signed cert was working again in Chrome! Bonus!
For an in-depth explanation for Studio 2015 onwards which should help you fix it on custom ports go here...
Stackoverflow
Thanks Martin, I am not using my local IIS instance, I prefer the [previously] low friction IIS Express approach. Thanks for the link but trust me, I have spent countless hours going through and trying the advice in hundreds of posts like that (and including that one). It does not provide a solution to my problem.
Having just quickly checked I also have the same issue in local IIS so now wondering if it is related somehow to firewall/anti-virus. I will check again when I have some available time.
Hi Simon
I didn't assume that you were, I don't even have IIS installed on my dev machine any more. I took the same route with SQL and just run localDB. Save's on start-up time, resources and generally easier to manage.
The url mostly covers IIS Express from what I can tell.
But anyway if you feel you've got it covered, np.
M.
Thanks Martin. I'll update the thread if I ever find the cause/solution.
Hi, Simon Have the same trouble. Did you found a solution?
Hi Simon
I also found this article which (last entry/reply) discusses how to use netsh to route the loopback address to a different IP and port.
specify ip and port
I haven't tried it myself yet, but for me sticking to 80/443 tends to do all I need anyway.
Hi, I had similar problem which was solved by running Visual Studio as Administrator. Hope this helps
Thank you so much!! Without Administrator, the application can run only on localhost.
Unfortunately not, I only ever run as administrator.
is working on a reply...