I am working on an asp.net core MVC web application, and i need to test the google captcha with it, and one requirement is to access my application inside visual studio 2019 using 127.0.0.1 instead of local host, but when i run my application >> try to access the following https://127.0.0.1:44363/
>> i got this error Bad Request - Invalid Hostname
.. any advice how i can access my web application using https://127.0.0.1:44363/
instead of using https://localhost:44363/
??
Thanks
Asked
Active
Viewed 1,472 times
2

John John
- 1
- 72
- 238
- 501
-
How do you run your application and what OS you use ? – Eugene Jul 10 '20 at 21:44
-
Try disabling SSL (switch to http). I think that's where your problem is. If the web traffic isn't leaving the computer, it doesn't really introduce a huge security threat. – itsme86 Jul 10 '20 at 21:45
-
@Eugene i run the application using visual studio 2019 and i am using windows 10 – John John Jul 10 '20 at 22:04
-
@itsme86 i tried accessing it using http as `http://127.0.0.1:57830/` but i got bad request also – John John Jul 10 '20 at 22:09
-
Is port 57830 HTTP or HTTPS? – itsme86 Jul 10 '20 at 22:38
-
@itsme86 it is http – John John Jul 10 '20 at 22:59
-
Does this answer your question? [C# Web - localhost:port works, 127.0.0.1:port doesn't work](https://stackoverflow.com/questions/23403912/c-sharp-web-localhostport-works-127-0-0-1port-doesnt-work) – Eugene Jul 15 '20 at 23:56
1 Answers
0
As a workaround you can map 127.0.0.1
to localhost
manually. To do so, go to hosts
file(location should be something like c:\Windows\System32\Drivers\etc\hosts
) and add following line and save the file:
127.0.0.1 localhost

Eugene
- 1,487
- 10
- 23
-
i already has this defined inside my hosts file `127.0.0.1 localhost` – John John Jul 10 '20 at 23:04
-
Check out this similar post https://stackoverflow.com/questions/23403912/c-sharp-web-localhostport-works-127-0-0-1port-doesnt-work – Eugene Jul 10 '20 at 23:10