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 inval
This solved my problem (sorry for my bad English):
open cmd as administrator and run command (Without the square brackets):
netsh http add urlacl url=http://[ip adress]:[port]/ user=everyone
in documents/iisexpress/config/applicationhost.config
and in your root project folder in (hidden) folder: .vs/config/applicationhost.config
you need add row to "site" tag:
<binding protocol="http" bindingInformation="*:8080:192.xxx.xxx.xxx" />
open "internet information services (iis) manager"
(to find it: in search in taskbar write "Turn Window features on or off" and open result and then check the checkbox "internet information service" and install that):
open "Windows Firewall With Advanced Security",
done.
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.
This page by Microsoft describes how to set up access to IIS Server Express from other computers on the local network.
In a nutshell:
1) from a command prompt with admin privileges:
netsh http add urlacl url=http://[your ip address]:8181/ user=everyone
2) In Windows Firewall with Advanced Security, create a new inbound rule for port 8181 to allow external connections
3) In applicationhost.config, in the node for your project, add:
<binding protocol="http" bindingInformation="*:8181:[your ip address]" />
Do NOT add (as was suggested in another answer):
<binding protocol="http" bindingInformation="*:8181:*" />
The above wildcard binding broke my access from http://192.168.1.6:8181/
Did you check the binding is IIS? (inetmgr.exe) It may not be registered to accept all hostnames on 8080.
For example, if you set it up for mysite.com:8080 and hit it at localhost:8080, IIS will get the request but not have a hostname binding to match so it rejects.
Outside of that, you should check the IIS logs (C:\inetpub\logs\wmsvc#) on the server and see if you are seeing your request. Then you'll know if its a problem on your client or on the server itself.
I saw the same error after using msdeploy to copy the application to a new server. It turned out that the bindings were still using the IP address from the previous server. So, double check IP address in the IIS bindings. (Seems obvious after the fact, but did not immediately occur to me to check it).
Make sure IIS is listening to your port.
In my case this was the issue. So I had to change my port to something else like 8083 and it solved this issue.