我的webconfig文件有问题:

本文关键字:有问题 文件 webconfig 我的 | 更新日期: 2023-09-27 17:59:24

   <compilation debug="false" targetFramework="4.0">

当那条线是红色时,我得到了这个错误:

Parser Error Message: Sections must only appear once per config file.  See the help topic <location> for exceptions.

我以为我也在重复机器配置文件中的一些内容,然后我去搜索配置属性,发现了这个:

                <section name="compilation" type="System.Web.Configuration.CompilationSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****" requirePermission="false"/>

我试图删除它,但它引起了问题,所以我把它放回原处。。

是什么导致了这个错误?

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.net>
    <mailSettings>
      <smtp from="example@example.com">
        <network host="****" enableSsl="true" defaultCredentials="false" port="587" userName="****" password="****"/>
      </smtp>
    </mailSettings>
  </system.net>
  <connectionStrings>
    <clear/>
    <add name="SqlState" connectionString="Data Source=****;DataBase=****;Integrated Security=True" providerName="System.Data.SqlClient"/>
    <add name="YourGuruDB" connectionString="Data Source=****;Initial Catalog=****;Integrated Security=True"/>
    <add name="modelConnectionString" connectionString="Data Source=****;AttachDbFilename='****';Integrated Security=True;User Instance=True;Trusted_Connection=Yes;" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <sessionState mode="SQLServer" sqlConnectionString="SqlState" allowCustomSqlDatabase="true" cookieless="false" timeout="20"/>
    <compilation debug="true"/>
    <authentication mode="Forms">
      <forms name=".MyCookie" loginUrl="~/Registration.aspx" protection="All" timeout="30" path="/">
        <credentials passwordFormat="MD5">
          <user name="****" password="****"/>
        </credentials>
      </forms>
    </authentication>
    <authorization>
      <deny users="?"/>
      <allow users="*"/>
    </authorization>
    <roleManager enabled="true" defaultProvider="MyRoleProvider">
      <providers>
        <clear/>
        <add name="MyRoleProvider" applicationName="/" connectionStringName="modelConnectionString" type="System.Web.Security.SqlRoleProvider"/>
      </providers>
    </roleManager>
    <membership defaultProvider="MyMembershipProvider">
      <providers>
        <clear/>
        <add name="MyMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="modelConnectionString" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" enablePasswordReset="true" maxInvalidPasswordAttempts="1000" passwordAttemptWindow="4000" enablePasswordRetrieval="true" requiresUniqueEmail="false" passwordFormat="Encrypted" applicationName="/WebSite10"/>
      </providers>
    </membership>

    <machineKey validationKey="****" decryptionKey="****" validation="SHA1" decryption="AES"/>
    <compilation debug="false" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
  </system.web>
</configuration>

我的webconfig文件有问题:

web.config中有两个编译标记:

<sessionState mode="SQLServer" sqlConnectionString="SqlState" allowCustomSqlDatabase="true" cookieless="false" timeout="20"/>
<compilation debug="true"/>

和你最初发布的那个。

如果没有web.config的其余部分,很难看到发生了什么。这是您正在编辑的网站/web应用程序根web.config吗?

你有多个"编译"部分吗?

无论如何,这只是猜测,因为我们需要更多的信息,但似乎你的一个或多个web配置文件格式不正确。。。

我认为您不希望在machine.config中包含编译部分-每个网站/应用程序都需要能够在本地拥有此部分,以便引入所需的程序集。

我会将其从machine.config中删除。