每次重新打开Visual Studio时,applicationhost.config都会更改

时间:2017-07-30 13:25:44

标签: asp.net-mvc visual-studio-2017 iis-express

我正在创建asp.net-mvc应用程序,我使用端口转发能够从外部测试我的项目。但每次我重新打开并构建我的应用程序IIS-Express都会更改applicationhost.config,而我能看到的每一个都是错误。

重新开放前的文件:

        <site name="Project" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="path" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:61035:*" />
            </bindings>
        </site>

文件后:

        <site name="Project" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="path" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:61035:*" />
            </bindings>
        </site>
        <site name="Project(1)" id="3">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="path" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:61035:localhost" />
            </bindings>
        </site>

正如您所料,Project(1)正在由IIS-Express托管,每次重新打开Visual Studio时我都必须更改绑定到*:61035:*,因为它不断添加另一个站点,并忽略以前的站点

我能用它做什么吗?

1 个答案:

答案 0 :(得分:2)

我找到了一个非常简单的解决方案。

我只需要改变:

<site name="Project" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="path" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:61035:*" />
    </bindings>
</site>

为:

<site name="Project" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="path" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:61035:*" />
        <binding protocol="http" bindingInformation="*:61035:localhost" />
    </bindings>
</site>

现在一切正常,每次重新打开Visual Studio时都不必编辑此文件。