错误的请求-从LAN上访问localhost Web API或Web App时,主机名无效
我有一个ASP .Net Core 1.1 Web API和Web App在Windows 10上的Visual Studio 2017上的本地主机上运行。
I have an ASP .Net Core 1.1 Web API and Web App running on my localhost from Visual Studio 2017 on Windows 10.
运行项目时, API在 http:// localhost:50082 / api / 上运行,而Web应用程序在 http:// localhost:60856 /
When I run the projects, the API runs on http://localhost:50082/api/ and the web app on http://localhost:60856/
但是,如果局域网上的其他人试图访问它(使用我计算机的IP地址- http://192.168.1.101: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
错误。实际上,我也使用IP地址也收到此错误我已经在C:\Users\Documents\IISExpress\config\applicationhost.config文件中尝试了十几种变体,例如:
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>
和
<bindings>
<binding protocol="http" bindingInformation="*:60856:" />
</bindings>
每次都重新启动项目(因此重新启动IIS Express),但似乎没有任何效果。有任何想法吗?
restarting the projects (and therefore IIS Express) every time, but nothing seems to work. Any ideas?
IIS Express默认情况下不允许远程连接。 这篇文章说明了如何激活它。
IIS Express does not allow remote connections by default. This post explains how to activate it.
我认为,如果您设置本地IIS并将应用程序发布到已配置的IIS文件夹,您会更好。
In my opinion, you would be better off if you setup local IIS and publish the app to the configured IIS folder.
我已经尝试过HTTP.SYS其他情况下的配置,有时无论是重新启动还是Windows更新,配置都将丢失...但是您可能不会发生这种情况...
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...