Bad Request - Invalid Hostname IIS7

后端 未结 15 2115
一个人的身影
一个人的身影 2020-12-05 03:53

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

相关标签:
15条回答
  • 2020-12-05 04:19

    This solved my problem (sorry for my bad English):

    1. open cmd as administrator and run command (Without the square brackets):
      netsh http add urlacl url=http://[ip adress]:[port]/ user=everyone

    2. 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" />

    3. 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):

      1. in left screen click: computer-name --> Sites --> Default Web Site and
      2. then click in right screen "Binding"
      3. click Add button
      4. write what you need and press "OK".
    4. open "Windows Firewall With Advanced Security",

      1. in left screen press "Inbound Rules" and then
      2. press in right screen "New Rule..."
      3. check port and press Next,
      4. check TCP and your port and press Next,
      5. check "Allow the connection" and press Next,
      6. check all checkbox and press Next,
      7. write name and press Finish.
    5. done.

    0 讨论(0)
  • 2020-12-05 04:19

    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.

    0 讨论(0)
  • 2020-12-05 04:20

    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/

    0 讨论(0)
  • 2020-12-05 04:23

    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.

    0 讨论(0)
  • 2020-12-05 04:25

    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).

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题