根据其他 SO 问题,该问题已通过编辑主机文件和应用程序主机文件得到解决。这两个文件已经在我的机器上正确设置。在我升级到 visual studio 2015 SP1 后,这个错误开始出现
http://bdtest.localhost:50119/返回错误请求
主机文件 -
localhost 名称解析在 DNS 本身内处理。
127.0.0.1 本地主机
::1 本地主机
127.0.0.1 bdtest.localhost
应用程序主机文件
<site name="BizDox.Web" id="2">
<application path="/" applicationPool="Clr4ClassicAppPool">
<virtualDirectory path="/" physicalPath="C:\Source\BizDox\Summer2015-Navigation\BizDox.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50119:*"/>
<binding protocol="http" bindingInformation="*:50119:localhost" />
<binding protocol="http" bindingInformation="*:50119:bdtest.localhost" />
<binding protocol="http" bindingInformation="*:50119:demo.localhost" />
<binding protocol="http" bindingInformation="*:50119:diy.localhost" />
<binding protocol="http" bindingInformation="*:50119:akuity.localhost" />
<binding protocol="http" bindingInformation="*:50119:owlsfactory.localhost" />
<binding protocol="http" bindingInformation="*:50119:rtp.localhost" />
<binding protocol="http" bindingInformation="*:50119:barebones.localhost" />
<binding protocol="http" bindingInformation="*:50119:sygnet.localhost" />
<binding protocol="http" bindingInformation="*:50119:firstsolution.localhost" />
</bindings>
</site>
如果您的主机文件设置正确,还有什么可能导致 400 错误?
我以管理员身份运行 VS2015。
最佳答案
VS 2015 将位于 mydocuments/iisexpress 中的默认 applicationhost.config 文件更改为项目特定的 applicationhost.config 文件。您可以在隐藏的 .vs
下的 Web 项目中找到它文件夹。
您的两个选择是打开此文件夹并编辑 applicatoinhost.config 文件或告诉 .proj 文件使用位于 documents/iisexpress 中的默认配置文件。您只需将此行更改/添加到 .proj 文件。
<UseGlobalApplicationHostFile>true</UseGlobalApplicationHostFile>
将此添加到 <PropertyGroup>
内文件的顶部标签
确保关闭 VS 并重新打开它以使更改生效。还要确保以管理员身份运行。
关于asp.net-mvc - 错误请求 - 无效主机名 - 主机文件已修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34620522/