错误请求 - IIS8中的无效主机名

问题描述 投票:0回答:1

enter image description here

enter image description hereenter image description here

我正在做一个asp.net core应用程序,但我的项目从调试模式(使用f5)停止运行。我需要在本地IIS上托管它来调试代码。当在本地运行时,我得到这个错误 "Bad Request - Invalid Hostname"。

visual-studio-2017 iis-8
1个回答
0
投票

你可以尝试以下步骤来解决这个问题。

  1. 退出当前正在运行的IIS Express。
  2. 打开IIS Express的applicationhost.config,位于以下路径C:\Users/Documents/IISExpress\Config/applicationhost.config。
  3. 找到您正在开发的特定站点的条目(例如 "Test "在6306端口运行),例如。

    <site name="test" id="1">
    <application path="/" applicationPool="gratedAppPool">
        <virtualDirectory path="/" physicalPath="" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:6306:localhost" />
    </bindings>
    </site>
    
  4. 替换以下 bindingInformation=":6306:localhost" with bindingInformation=":6306:*"

  5. 保存文件。
  6. 在管理员模式下启动命令提示符,运行以下命令.netsh http add urlacl url=http:/*:6306 user=Everyone。
  7. 现在再次调试网站,你应该可以使用主机名访问网址。
© www.soinside.com 2019 - 2024. All rights reserved.