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

Joh*_*ika 3 asp.net-mvc visual-studio iis-express visual-studio-2015

我将我的ASP.NET MVC项目升级为使用Visual Studio,并Bad Request - Invalid Hostname出现了令人讨厌的错误.以前版本的Visual Studio已经记录了这个问题(例如,使用IIS Express自定义域),但我似乎找不到Visual Studio 2015的解决方案.

我使用许多自定义域(例如http://foo.testsite.local:1299)来运行我的网站.我以管理员身份运行Visual Studio,我在applicationhost.config中的绑定如下所示:

        <bindings>
          <binding protocol="http" bindingInformation="*:1299:" />
          <binding protocol="https" bindingInformation="*:44300:" />
        </bindings>
Run Code Online (Sandbox Code Playgroud)

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

HTTP/1.1 400 Bad Request

Bad Request - Invalid Hostname
Run Code Online (Sandbox Code Playgroud)

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

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

小智 7

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

<UseGlobalApplicationHostFile>
    true
<UseGlobalApplicationHostFile>
Run Code Online (Sandbox Code Playgroud)