Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test subdomain on localhost

Tags:

c#

asp.net

I want to test some subdomain features in an asp.net site. I read just to edit the hosts file and add 127.0.0.1 subdomain.domain.com and that should work.

But mine seems to not. I have flushed the dns, restarted, tried new browsers and still get error 500.

When I normal run the asp.net site from Visual Studio it goes to http://localhost:17365/ . How do I get the IP address for this?

I guess I don't get the whole picture and missing some pieces.

I ran netstat -n and see that the site is running on[::1]:17365 maybe thats why its not working under ipv4?

like image 786
Zach Avatar asked Dec 16 '22 12:12

Zach


2 Answers

The solution is very simple. After you have edit your host files adding a line as:

127.0.0.1 subdomain.domain.com

you run your site, the personal web starts and you get on your browser this

http://localhost:[PortNumber]/ (eg: http://localhost:17365/ )

just change it to

http://subdomain.domain.com:[PortNumber]/ (eg:http://subdomain.domain.com:17365/)

with your hand, type it on the url on your browser, and it will work.

like image 79
Aristos Avatar answered Jan 03 '23 12:01

Aristos


In visual studio when you go to run the site first change in the Website Properties > Use Dynamic PortstoFalse, then set the Port Numberto80, then run it.

It will by default launch http://localhost:80, however then in your browser visit subdomain.domain.com in your browser it will point to your debugging instance of your site (assuming you've still got that 127.0.0.1 subdomain.domain.com in your hosts file).

like image 27
Ryan McDonough Avatar answered Jan 03 '23 13:01

Ryan McDonough