asp.net-mvc - 错误请求 - 无效主机名 - 主机文件已修复

标签 asp.net-mvc asp.net-mvc-4

根据其他 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/

相关文章:

c#-4.0 - 将 JSON 对象发送到 Web API

jquery - 将 jquery 添加到空 MVC 项目

asp.net-mvc - 单击列表 MVC5 中的按钮时在模式中显示不同的详细信息

c# - 在网格 MVC 中显示对象

jquery - 用另一个 div-jquery 更改 div 的内容

javascript - 使用 asp.net mvc 查看包消息在按钮单击成功时无法正常工作?

jquery - 选择取消选择带有复选框的 kendo UI 网格行

jquery - 仅在 Internet Explorer 中引发未定义或 null 引用的 datepicker 元素

asp.net mvc4 ajax 操作链接

asp.net-mvc - ASP.NET MVC 跟踪问题