简体   繁体   English

为什么在ASP.NET中的Web配置中出现错误?

[英]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: 我是ASP.NET的初学者,并且在Web配置文件中出现此错误:

web config section must only appear once per config file Web配置部分必须在每个配置文件中仅出现一次

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. 我该如何解决这个问题?

You have section httpRuntime twice in your config file: 您的配置文件中有两次httpRuntime部分:

<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. 因此,为了解决此问题,请删除httpRuntime部分之一,并且配置文件应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM