Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 06, 2018 @ 09:40
    Simon Dingley
    2

    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:

    <site name="MyProject.www" id="1">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="D:\Repositories\Myproject\Myproject.www" />
        </application>
        <bindings>                  
            <binding protocol="http" bindingInformation="*:64970:" />
            <binding protocol="http" bindingInformation="*:64970:localhost" />
            <binding protocol="http" bindingInformation="*:64970:mycustomdomain.com.local" />
        </bindings>
    </site>
    

    I have added the url reservation as follows:

    netsh http add urlacl http://mycustomdomain.com.local:64970/ user=Everyone
    

    I have an entry in my host file as follows:

    127.0.0.1   mycustomdomain.com.local
    

    No matter what I try Chrome simply reports ERR_CONNECTION_REFUSED

    This site can’t be reached mycustomdomain.com.local refused to connect.

    Anyone else had any success with this?

    Thanks, Simon

  • Anthony Woodward 4 posts 74 karma points
    Jun 06, 2018 @ 12:58
    Anthony Woodward
    0

    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)

    netsh http delete urlacl http://mycustomdomain.com.local:64970/
    netsh http add urlacl url=https://mycustomdomain.com.local:XXXXX/ user=Everyone
    
  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 07, 2018 @ 08:45
    Simon Dingley
    0

    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

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jun 07, 2018 @ 10:06
    Martin Griffiths
    1

    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...

    <binding protocol="http" bindingInformation="*:80:yourdomain.com" /> <binding protocol="https" bindingInformation="*:443:yourdomain.com" />
    

    and in the HOSTS file

    127.0.0.1 yourdomain.com
    

    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

  • Barry 15 posts 56 karma points c-trib
    Jun 07, 2018 @ 22:00
    Barry
    0

    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.

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jun 13, 2018 @ 09:07
    Martin Griffiths
    0

    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.

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 13, 2018 @ 09:08
    Simon Dingley
    0

    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?

    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.

    Cheers, Simon

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 13, 2018 @ 09:14
    Simon Dingley
    0

    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?

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jun 13, 2018 @ 11:03
    Martin Griffiths
    0

    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!

    enter image description here

    For an in-depth explanation for Studio 2015 onwards which should help you fix it on custom ports go here...

    Stackoverflow

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 13, 2018 @ 11:10
    Simon Dingley
    0

    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.

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jun 13, 2018 @ 11:29
    Martin Griffiths
    0

    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.

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 13, 2018 @ 11:32
    Simon Dingley
    0

    Thanks Martin. I'll update the thread if I ever find the cause/solution.

  • Dmitriy 168 posts 588 karma points
    Sep 03, 2018 @ 12:25
    Dmitriy
    0

    Hi, Simon Have the same trouble. Did you found a solution?

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jun 07, 2018 @ 10:23
    Martin Griffiths
    0

    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.

  • Joseph James 1 post 71 karma points
    Apr 21, 2019 @ 08:36
    Joseph James
    0

    Hi, I had similar problem which was solved by running Visual Studio as Administrator. Hope this helps

  • Felipe Fantin 1 post 21 karma points
    Sep 28, 2021 @ 00:17
    Felipe Fantin
    0

    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.

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Apr 21, 2019 @ 10:55
    Simon Dingley
    0

    Unfortunately not, I only ever run as administrator.

Please Sign in or register to post replies

Write your reply to:

Draft