每个配置文件只能出现一次。有关例外,请参阅帮助主题<location>。为什么?</location>

时间:2011-06-16 14:21:00

标签: asp.net configuration

  

配置错误   描述:处理为此请求提供服务所需的配置文件时发生错误。请查看下面的具体错误详细信息并相应地修改配置文件。

<configuration>

  <system.net>
    <mailSettings>
      <smtp from="makovetskiyd@yahoo.co.uk">
        <network host="smtp.gmail.com" enableSsl="true" defaultCredentials="false" port="587" userName="****" password="****"/>
      </smtp>
    </mailSettings>
  </system.net>

  <connectionStrings>
    <clear/>
<add name="SqlState" connectionString="Data Source=localhost;DataBase=AnyNameOfServerState;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="YourGuruDB" connectionString="Data Source=DIMA-00AA1DA557;Initial Catalog=model;Integrated Security=True"/>
<add name="modelConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename='D:\Documents and Settings\Dima\My Documents\Visual Studio 2010\WebSites\WebSite10\App_Data\ASPNETDB.MDF';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="true" targetFramework="4.0">
  <assemblies>
    <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****"/>
    <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****"/>
    <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****"/>
    <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****"/>
  </assemblies>
</compilation>

3 个答案:

答案 0 :(得分:4)

你有两个编译标签

<compilation debug="true"/> 

<compilation debug="true" 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> 

答案 1 :(得分:0)

如果在配置文件中有两次Compilation元素,则会出现以下错误。只需拿出一个或另一个。

似乎有两个部分。

删除 <compilation>

离开 <compilation debug="true" >

答案 2 :(得分:0)

我在安装Ajax工具包后遇到了这个问题。如果您在web.config中安装ajax工具包之前添加了自定义控件,则为:

<pages>
    <controls> 
             <!--Your custom control class information-->      
             <add tagPrefix=".." namespace="..."/>      
    </controls>
 </pages>
删除标签后,

将其与ajaxToolkit部分合并:

<pages>   
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />    
        <!--Your custom control class information-->
        <add tagPrefix="..." namespace="..." />
      </controls>
</pages>