Bad Request - Invalid Hostname when accessing localhost Web API or Web App from across LAN

谁都会走 提交于 2020-01-02 03:28:27

问题


I have an ASP .Net Core 1.1 Web API and Web App running on my localhost from Visual Studio 2017 on Windows 10.

When I run the projects, the API runs on http://localhost:50082/api/ and the web app on http://localhost:60856/

However, if others on the LAN try to access it (using my computer's IP address - http://192.168.1.101:60856/ they get a

Bad Request - Invalid Hostname

Error. In fact,. I get this error too of I use my IP address. I've tried about a dozen variations in my C:\Users\Documents\IISExpress\config\applicationhost.config file, such as:

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

and

<bindings>
<binding protocol="http" bindingInformation="*:60856:" />
</bindings>

restarting the projects (and therefore IIS Express) every time, but nothing seems to work. Any ideas?


回答1:


IIS Express does not allow remote connections by default. This post explains how to activate it.

In my opinion, you would be better off if you setup local IIS and publish the app to the configured IIS folder.

I already tried HTTP.SYS configurations for other situations, and sometimes the configs are lost whether on restarts or windows updates... But this may not happen to you...



来源:https://stackoverflow.com/questions/45147241/bad-request-invalid-hostname-when-accessing-localhost-web-api-or-web-app-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!