我必须手动编辑 applicationhost.config 以将特定绑定添加到 IIS Express

Must I manually edit the applicationhost.config to add specific bindings to IIS Express

我正在翻新一个 https asp.net 网站,该网站根据用户访问的 URL 使用两种不同的外观呈现。当我们将网站上线时,我们可以使用 IIS 管理器中的绑定来设置特定的绑定来满足这一点。我在我的开发环境中使用 IIS Express 并且在 Visual Studio 中看不到任何地方来编辑绑定。因此,为了获得我想要的功能,我手动编辑 applicationhost.config 并添加我需要使其工作的行(提到苹果和橘子的行):

<site name="MySite.PresentationLayer" id="1">
    <application path="/" applicationPool="MySiteAppPool">
        <virtualDirectory path="/" physicalPath="E:\TFS\Dev\WebApps\MySite\Presentation" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:44301:localhost" />
        <binding protocol="https" bindingInformation="*:44301:localhost" />
        <binding protocol="https" bindingInformation="*:44435:apples-mysite" />
        <binding protocol="https" bindingInformation="*:44436:oranges-mysite" />
    </bindings>
</site>

我可以在 Visual Studio 中执行此操作还是手动编辑 applicationhost.config 执行此操作的最佳方法?

简单的答案是肯定的,就目前使用 Visual Studio 2017 而言,您必须手动编辑 applicationhost.config ($SolutionDir.vs\config\applicationHost.config) 以设置特定绑定从 IIS Express 中获取上述功能。

上面评论中提到的 Jexusmanager 可以管理此文件以及您的实际 IIS 配置,如果您在这里结束,可能值得一试。