How to avoid adding httpruntime tag to web.config at deploy

3k Views Asked by At

I get the error Config section 'System.web/httpRuntime' already defined when I deploy our application to our development environment.

After deploying, if I push the Authentication button on the IIS servers management overview, I get the following error message:

IIS server error message

The Web.Config on the IIS has the <system.web> element looking like this:

<system.web>
    <compilation targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="None" />
    <authorization>
        <deny users="?" />
    </authorization>
    <httpRuntime requestValidationMode="4.5" />
</system.web>

The problem is clearly that somehow both <httpRuntime targetFramework="4.5" /> and <httpRuntime requestValidationMode="4.5" /> are being added to <system.web>. My problem is that I can not figure out how the <httpruntime> tag is being added to my Web.Config when deployed to our development environment. It does not happen on my local machine. We use Octopus Deploy as deployment tool (I'm not sure if that matters).

The Web.Config <system.web> in the project looks like this

<system.web>
  <compilation debug="true" targetFramework="4.5.2"/>
</system.web>

and the Web.Release.Config <system.web>looks like this

 <system.web>
  <compilation xdt:Transform="RemoveAttributes(debug)" />

  <authentication xdt:Transform="Insert" mode="None" />

  <authorization xdt:Transform="Insert">
    <deny users="?" />
  </authorization>
</system.web>

I'm not certain which parts of the project can have an influence on this so I'm adding in the following. Please let me know if I have left out any other relevant parts.

The solution consists of two project. A Web project and a Class Library. The Class Library project has this in the app.config:

<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>

which I think might be causing some of the problem (based on this article).

0

There are 0 best solutions below