2015-10-30 52 views
0

我的問題顯然與我的web.config文件早些時候:HTML button sending input text data to ASP side。我解決了它實際上installing the System.Web.Providers package。但是,當我再次運行我的代碼時,我得到了this screen。它說,這:Config section 'system.web/profile' already defined. Sections must only appear once per config file. See the help topic <location> for exceptions配置部分'system.web/profile'已經定義

這裏是我的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> 

,顯然,這個問題是與線50:<profile defaultProvider="DefaultProfileProvider">。但是,當我評論這一點時,它會抱怨它之前的第一個標籤。

我該如何解決這個問題?

+0

你顯然在你的web.config中定義了兩個 「」 標籤.. <輪廓defaultProvider = 「AspNetSqlProfileProvider」 > 和 Vinay

+0

我可能應該提到我正在使用Microsoft Visual Studio Ultimate 2013(儘管如此,我不知道這很重要)。 –

回答

0

您有兩個<profile ...>和兩個<sessionState ...>部分。

刪除這些,看看它是怎麼回事。

<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> 

再往下

<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> 

完整版如下

<?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> 
+0

我發表了一條評論,然後代碼在第55行上抱怨''我評論說已經標記出來了,然後我回到了第1位(儘管我已經安裝了'System.Web.Providers' already! –

+0

您也有兩個''節。我已更新答案 – Kirk

+0

您的解決方案對我無效:http://imgur.com/XztFpyX –