Bad Request - Invalid Hostname IIS7

后端 未结 15 2114
一个人的身影
一个人的身影 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:31

    For Visual Studio 2017 and Visual 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 work

    <bindings>
        <binding protocol="http" bindingInformation="*:8802:localhost" />
        <binding protocol="http" bindingInformation="*:8802:127.0.0.1" />
    </bindings>
    

    Syntax: https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.administration.binding.bindinginformation?view=iis-dotnet

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

    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.

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

    Check your local hosts file (C:\Windows\System32\drivers\etc\hosts for example). In my case I had previously used this to point a URL to a dev box and then forgotten about it. When I then reused the same URL I kept getting Bad Request (Invalid Hostname) because the traffic was going to the wrong server.

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