0

Windows 11 + all updates. Visual Studio 2022 + all updates

I have a website which can run on https://localhost:44313/ in my CMS i have configured it to use a test domain.

I have set a test domain set against it i.e. www.testing.com and testing.com and i amended the hosts file as below (as an admin)

localhost:44313 testing.com www.testing.com

I ran

ipconfig /flushdns

and opened up the URL testing.com in a private browser (to avoid and caching issues) and it never works?

Is there a way to get this working in this manner so i can test the site in this manner? i have usually moved the site to a Windows Server (2012 and 2019) where i can setup IIS and test but was wondering if there is a way to do this on my local machine against the address provided by Visual Studio?

Computer
  • 125
  • 3
  • This syntax isn't supported by the `hosts` file. – harrymc Jul 26 '23 at 16:24
  • you cannot use host files (or really any host naming system) to indicate ports. if you are operating on a non-standard HTTP/HTTPS port, you will still need to include the port number in your URLs. one way to get around this is to use a reverse proxy or load balancer listening on 80/443, and relaying that traffic to 44313. That can solve your naming issue as well, if you want systems other than yours to be able to access the service by name (which is critical for HTTPS). – Frank Thomas Jul 26 '23 at 16:29
  • so you may want to install IIS on your workstation instead of using IISExpress. then you could use different hostnames for different sites, while using 80/443. your project can be configured to use local IIS instead of IISExpress, and you can have VS create the app pool for you. if you need more detailed configuration on the app pool, you can do that in the inetmanager for IIS. – Frank Thomas Jul 26 '23 at 19:20

1 Answers1

1

Add this to C:\Windows\System32\drivers\etc\hosts:

127.0.0.1 testing.com
127.0.0.1 www.testing.com

* You may need to re-open your browser for changes to take effect.

This mapping will automatically apply to any non-standard ports.

For example if you run servers on port 44313 and 44314 those will be accessible at their respective domains:

testing.com:44313
testing.com:44314
oxou
  • 341
  • 11