简体   繁体   English

配置部分“ system.web / profile”已定义

[英]Config section 'system.web/profile' already defined

I had problem apparently with my web.config file earlier: HTML button sending input text data to ASP side . 我以前的web.config文件显然有问题: HTML按钮将输入文本数据发送到ASP端 I resolved it by actually installing the System.Web.Providers package . 我通过实际安装System.Web.Providers包来解决它。 However, when I ran my code again, I get this screen . 但是,当我再次运行代码时,我得到了这个屏幕 It says this: Config section 'system.web/profile' already defined. Sections must only appear once per config file. See the help topic <location> for exceptions 它说: Config section 'system.web/profile' already defined. Sections must only appear once per config file. See the help topic <location> for exceptions Config section 'system.web/profile' already defined. Sections must only appear once per config file. See the help topic <location> for exceptions

Here is my web.config: 这是我的web.config:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
    <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <system.web>
        <authentication mode="Forms" />
        <compilation debug="true" targetFramework="4.0" />
        <profile defaultProvider="AspNetSqlProfileProvider">
            <providers>
                <clear />
                <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" applicationName="/" />
            </providers>
        </profile>
        <membership defaultProvider="DefaultMembershipProvider">
            <providers>
            <clear />
            <add connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /></providers>
        </membership>
        <roleManager enabled="true" defaultProvider="DefaultRoleProvider">
            <providers>
                <clear />
                <add connectionStringName="LocalSqlServer" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
                <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
            </providers>
        </roleManager>
        <!--
                If you are deploying to a cloud environment that has multiple web server instances,
                you should change session state mode from "InProc" to "Custom". In addition,
                change the connection string named "DefaultConnection" to connect to an instance
                of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
          -->
        <!--
                If you are deploying to a cloud environment that has multiple web server instances,
                you should change session state mode from "InProc" to "Custom". In addition,
                change the connection string named "DefaultConnection" to connect to an instance
                of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
        -->
        <sessionState mode="Custom" customProvider="DefaultSessionProvider">
            <providers>
                <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="LocalSqlServer" />
            </providers>
        </sessionState>
        <profile defaultProvider="DefaultProfileProvider">
            <providers>
                <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
            </providers>
        </profile>
        <sessionState mode="InProc" customProvider="DefaultSessionProvider">
            <providers>
                <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
            </providers>
        </sessionState>
    </system.web>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
            <providers>
                <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
            </providers>
    </entityFramework>
    <connectionStrings>
        <remove name="LocalSqlServer" />
            <add name="LocalSqlServer" connectionString="Data Source=roosterdbdev;Database=RoosterDatabase;User Id=; Password=;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

and apparently, the problem is with line 50: <profile defaultProvider="DefaultProfileProvider"> . 显然,问题出在第50行: <profile defaultProvider="DefaultProfileProvider"> However, when I comment that out, it complains about first tag before it. 但是,当我将其注释掉时,它会抱怨之前的第一个标签。

How do I fix this? 我该如何解决?

You have two <profile ...> and two <sessionState ...> sections in there. 您在那里有两个<profile ...>和两个<sessionState ...>部分。

Remove these and see how it goes. 删除这些,看看如何进行。

<profile defaultProvider="AspNetSqlProfileProvider">
     <providers>
           <clear />
           <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" applicationName="/" />
     </providers>
</profile>

Further down 再向下

<sessionState mode="Custom" customProvider="DefaultSessionProvider">
     <providers>
          <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="LocalSqlServer" />
     </providers>
</sessionState>

Full version below 完整版本如下

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
    <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <system.web>
        <authentication mode="Forms" />
        <compilation debug="true" targetFramework="4.0" />
        <profile defaultProvider="AspNetSqlProfileProvider">
            <providers>
                <clear />
                <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" applicationName="/" />
            </providers>
        </profile>
        <membership defaultProvider="DefaultMembershipProvider">
            <providers>
            <clear />
            <add connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /></providers>
        </membership>
        <roleManager enabled="true" defaultProvider="DefaultRoleProvider">
            <providers>
                <clear />
                <add connectionStringName="LocalSqlServer" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
                <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
            </providers>
        </roleManager>
        <!--
                If you are deploying to a cloud environment that has multiple web server instances,
                you should change session state mode from "InProc" to "Custom". In addition,
                change the connection string named "DefaultConnection" to connect to an instance
                of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
          -->
        <!--
                If you are deploying to a cloud environment that has multiple web server instances,
                you should change session state mode from "InProc" to "Custom". In addition,
                change the connection string named "DefaultConnection" to connect to an instance
                of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
        -->
        <profile defaultProvider="DefaultProfileProvider">
            <providers>
                <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
            </providers>
        </profile>
        <sessionState mode="InProc" customProvider="DefaultSessionProvider">
            <providers>
                <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
            </providers>
        </sessionState>
    </system.web>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
            <providers>
                <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
            </providers>
    </entityFramework>
    <connectionStrings>
        <remove name="LocalSqlServer" />
            <add name="LocalSqlServer" connectionString="Data Source=roosterdbdev;Database=RoosterDatabase;User Id=blah; Password=blah;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

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

相关问题 如何从web.config中读取system.web部分 - How to read system.web section from web.config 从web.config system.web部分检索值 - Retrieve value from web.config system.web section 可以在Web.config中加密system.web / membership / providers吗? - Possible to encrypt system.web/membership/providers in Web.config? 路由声明它在 system.web 中定义,但未找到错误 - Route claim it is defined in system.web but it not found error 对类型“IDataSource”的引用声称它在“System.Web”中定义,但找不到 - Reference to type 'IDataSource' claims it is defined in 'System.Web', but it could not be found 引用类型“”声称它在“ System.Web”中定义,但找不到 - Reference to type '' claims it is defined in 'System.Web', but it could not be found System.Web 不可用 - System.Web not available 对“HttpContextBase”类型的引用声称它是在“System.Web”中定义的,但找不到 - Reference to type 'HttpContextBase' claims it is defined in 'System.Web' but it could not be found 我的ASP.NET Web应用程序中web.config文件的system.web部分中的调试参数 - Debug parameter in system.web part of the web.config file in my ASP.NET web application 为什么system.web不可用? - why is system.web not available?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM