behzad razzaqi behzad razzaqi - 4 months ago 19
ASP.NET (C#) Question

Why am I getting an error in web config in ASP.NET?

I'm a beginner in ASP.NET and in the web config file get the this error:



web config section must only appear once per config file


My web config file:

<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
<compilation targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<httpRuntime/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/langversion:4 /nowarn:1659;1699;1701">
<providerOption name="CompilerVersion" value="v4.0"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
<connectionStrings>
<add name="myCaseLoginEntities" connectionString="metadata=res://*/MyEntity.LoginModel.csdl|res://*/MyEntity.LoginModel.ssdl|res://*/MyEntity.LoginModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=myCase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
<add name="myCaseConnectionString" connectionString="Data Source=.;Initial Catalog=myCase;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="CaseManagementConnectionString" connectionString="Data Source=.;Initial Catalog=CaseManagement;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>


I added this line to that file:

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />


Before that I did not have any errors. How can I solve that problem Thanks.

Answer

You have section httpRuntime twice in your config file:

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

and

<httpRuntime/>

Just like it says in the error message that you posted, section must only appear once per config file. So in order to fix the issue remove one of the httpRuntime sections and configuration file should be valid.