Search code examples
asp.net-mvcvisual-studio-2017iis-express

applicationhost.config is beeing changed every time I reopen Visual Studio


I am creating asp.net-mvc application and I use port forwarding to be able to test my project from the outside. But every single time I reopen and build my application IIS-Express changes applicationhost.config and everyting i can see is error.

File before reopening:

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

File after:

        <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>

And as you may expect, Project(1) is beeing hosted by IIS-Express and I have to change binding to *:61035:* each time I reopen Visual Studio, because it keeps adding another site, and ignores previous ones.

Is there anything I can do with it?


Solution

  • I found a really simple solution to this.

    I only had to change:

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

    to:

    <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>
    

    Now everything works well, and I don't have to edit this file every time I reopen Visual Studio.