代码之家  ›  专栏  ›  技术社区  ›  Johnny Oshika

Visual Studio 2015:IIS Express中的自定义域-主机名无效

  •  3
  • Johnny Oshika  · 技术社区  · 9 年前

    我升级了ASP。NET MVC项目使用Visual Studio Bad Request - Invalid Hostname 出现错误。在以前的Visual Studio版本(例如。 Using Custom Domains With IIS Express ),但我似乎找不到Visual Studio 2015的解决方案。

    我使用许多自定义域(例如。 http://foo.testsite.local:1299 )运行我的网站。我以管理员身份运行VisualStudio,并在applicationhost中运行绑定。配置如下:

            <bindings>
              <binding protocol="http" bindingInformation="*:1299:" />
              <binding protocol="https" bindingInformation="*:44300:" />
            </bindings>
    

    这在Visual Studio 2013中运行得很好,但出于某种原因,运行我的ASP。Visual Studio 2015中的NET MVC应用程序返回:

    HTTP/1.1 400 Bad Request
    
    Bad Request - Invalid Hostname
    

    有解决办法吗?我需要在绑定中使用通配符,而不是硬编码的URL,因为我的应用程序支持多个域名(包括自定义子域)。

    我应该注意到 http://localhost:1299 可以使用这些设置。

    2 回复  |  直到 8 年前
        1
  •  7
  •   Eonasdan Alex Mckay    9 年前

    默认情况下,VS 2015解决方案不再使用应用程序主机。用户文件夹中的配置文件。相反,他们在解决方案下的.vs\config文件夹中动态创建一个。如果要使用用户文件夹中的全局文件,请在项目文件中设置以下属性。这是每个项目的设置。

    <UseGlobalApplicationHostFile>
        true
    <UseGlobalApplicationHostFile>
    
        2
  •  2
  •   mbungo paulo    8 年前
    1. 转到路径=C:\Users\(用户名)\Documents\Visual Studio 2015\Projects\{您的项目文件夹}\.vs\config。
    2. 编辑文件applicationhost。配置如下: 更改绑定协议=“http”bindingInformation=“ :1743:localhost“到 binding protocol=“http”bindingInformation=“ :1743:*"
    3. 以管理员身份打开cmd并键入: netsh http add urlacl url=http://*:1743/user=everyone