When I try to hit my web app on port 8080 I get the following error
Bad Request - Invalid Hostname
HTTP Error 400. The request hostname is invalid.
I don't even know where to begin to diagnose this problem
When I try to hit my web app on port 8080 I get the following error
Bad Request - Invalid Hostname
HTTP Error 400. The request hostname is invalid.
I don't even know where to begin to diagnose this problem
FWIW, if you'd like to just allow requests directed to any hostname/ip then you can set your binding like so:
I use this binding so that I can load a VM with IE6 and then debug my application.
EDIT: While using IIS Express to debug, the default location for this option's config file is
Double check the exact URL you're providing. I saw this error when I missed off the route prefix defined in ASP.NET so it didn't know where to route the request.
Don't forget to bind to the IPv6 address as well! I was trying to add a site on 127.0.0.1 using localhost and got the bad request/invalid hostname error. When I pinged localhost it resolved to ::1 since IPv6 was enabled so I just had to add the additional binding to fix the issue.
For
Visual Studio 2017
andVisual Studio 2015
,IIS Express
settings is stored in the hidden.vs
directory and the path is something like this.vs\config\applicationhost.config
, add binding like below will workI'm not sure if this was your problem but for anyone that's trying to access his web application from his machine and having this problem:
Make sure you're connecting to
127.0.0.1
(a.k.alocalhost
) and not to your external IP address.Your URL should be something like
http://localhost:8181/
orhttp://127.0.0.1:8181
and nothttp://YourExternalIPaddress:8181/
.Additional information:
The reason this works is because your firewall may block your own request. It can be a firewall on your OS and it can be (the usual) your router.
When you connect to your external IP address, you connect to you from the internet, as if you were a stranger (or a hacker).
However when you connect to your localhost, you connect locally as yourself and the block is obviously not needed (& avoided altogether).
this slove my problem :
(sorry for my bad english)
1.) open cmd an adminstor and run command (Without the square brackets): netsh http add urlacl url=http://[ip adress]:[port]/ user=everyone
2.) documents/iisexpress/config/applicationhost.config and in your root project folder in folder (hidden folder) .vs/config/applicationhost.config you need add row to "site" tag:
3.) open "internet information services (iis) manager", (if is not find: in serch in tasckbar write "Turn Window features on or off" and open resulet and then check the checkbox "internet information service" and its install that) in left screen click computer-name-->Sites-->Default Web Site and then click in right screen "Binding" click Add button wirte what yuo need and press OK.
4.) open "Windows Firewall With Advanced Security", in left screen press "Inbound Rules" and then press in right screen "New Rule..." check port and press Next, check TCP and your port and press Next, check "Allow the connaction" and press Next, check all checkbox and press Next, wirte name and press Finish.
done.