locked
Web.Config error RRS feed

  • Question

  • User1421620300 posted

    Can someone please explain to my why I keep ghetting the following error?

    <configuration>
    <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    </configSections>
    <connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ContosoUniversity-20140501183858;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ContosoUniversity-20140501183858.mdf" />
    </connectionStrings>
    <appSettings>
    <connectionStrings>      //error is here!!!
    <add name="SchoolContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
    </connectionStrings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    </appSettings>
    <system.web>

    Wednesday, May 7, 2014 12:54 PM

Answers

  • User753101303 posted

    Hi,

    It is misplaced. You are inside appSettings and you have another connectionStrings section a bit ealier outside of appSettings so it would give rather something such as :

    ...
    <connectionStrings>
     <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ContosoUniversity-20140501183858;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ContosoUniversity-20140501183858.mdf" />
     <add name="SchoolContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
     </connectionStrings>
     <appSettings>
     <add key="webpages:Version" value="2.0.0.0" />
     <add key="webpages:Enabled" value="false" />
     <add key="PreserveLoginUrl" value="true" />
     <add key="ClientValidationEnabled" value="true" />
     <add key="UnobtrusiveJavaScriptEnabled" value="true" />
     </appSettings>
    ...


    If it doesn't help or still have an error, please quote the exact error message (or the best english translation you can do).

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 7, 2014 1:05 PM
  • User-1454326058 posted

    Hi Markus33,

    The DefaultConnection should be in the connectionStrings section.

    <configuration>
     <configSections>
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
     </configSections>
    
     
    
    
     <connectionStrings>
     <add name="SchoolContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
    
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ContosoUniversity-20140501183858;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ContosoUniversity-20140501183858.mdf" />
    
     </connectionStrings>
     <appSettings>
     <add key="webpages:Version" value="2.0.0.0" />
     <add key="webpages:Enabled" value="false" />
     <add key="PreserveLoginUrl" value="true" />
     <add key="ClientValidationEnabled" value="true" />
     <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    
     </appSettings>
     <system.web>

    Thanks

    Best Regards              

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 8, 2014 2:12 AM

All replies

  • User753101303 posted

    Hi,

    It is misplaced. You are inside appSettings and you have another connectionStrings section a bit ealier outside of appSettings so it would give rather something such as :

    ...
    <connectionStrings>
     <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ContosoUniversity-20140501183858;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ContosoUniversity-20140501183858.mdf" />
     <add name="SchoolContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
     </connectionStrings>
     <appSettings>
     <add key="webpages:Version" value="2.0.0.0" />
     <add key="webpages:Enabled" value="false" />
     <add key="PreserveLoginUrl" value="true" />
     <add key="ClientValidationEnabled" value="true" />
     <add key="UnobtrusiveJavaScriptEnabled" value="true" />
     </appSettings>
    ...


    If it doesn't help or still have an error, please quote the exact error message (or the best english translation you can do).

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 7, 2014 1:05 PM
  • User1421620300 posted

    I have tried to correct my solution with the code but it gives the same error! 

    Warning 1 The element 'configSections' has invalid child element 'connectionStrings'. List of possible elements expected: 'section, sectionGroup'. C:\Users\Andrew\Documents\Visual Studio 2012\CU1\ContosoUniversity\Web.config 10 6 ContosoUniversity
    Warning 2 The element 'entityFramework' has invalid child element 'providers'. C:\Users\Andrew\Documents\Visual Studio 2012\CU1\ContosoUniversity\Web.config 91 6 ContosoUniversity
    Error 3 Unrecognized element. C:\Users\Andrew\Documents\Visual Studio 2012\CU1\ContosoUniversity\Web.config 10

    Config Source:

        9:     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
       10:     <connectionStrings>
       11:       <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ContosoUniversity-20140501183858;Integrated Security=SSPI;AttachDBFil
    Wednesday, May 7, 2014 5:27 PM
  • User753101303 posted

    It seems your introduced another error. Now connectionStrings is inside configSections when it should follow it that is now you likely have :

    <configSections>             : open the configSections
    <section etc/>                  : declare a section inside configSections
    <connectionsStrings>      : adds a connectionStrings child wiithin the opened congiSections which is not valid

    When previously you had :

    <configSections>             : open the configSections
    <section etc/>                  : declare a section isnide configSections
    </configSections>            : closes configSection
    <connectionStrings>        : now opens a section for connectionStrings

    Wednesday, May 7, 2014 5:40 PM
  • User1421620300 posted

    Here is the webconfig at the moment.. It still has the error! Really difficult to corrrect to me.

    <configuration>
    <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    </configSections>

    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ContosoUniversity-20140501183858;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ContosoUniversity-20140501183858.mdf" />


    <connectionStrings>
    <add name="SchoolContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
    </connectionStrings>
    <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />

    </appSettings>
    <system.web>

    Wednesday, May 7, 2014 5:54 PM
  • User-1716253493 posted

    What error message?

    Wednesday, May 7, 2014 10:40 PM
  • User-1454326058 posted

    Hi Markus33,

    The DefaultConnection should be in the connectionStrings section.

    <configuration>
     <configSections>
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
     </configSections>
    
     
    
    
     <connectionStrings>
     <add name="SchoolContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
    
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ContosoUniversity-20140501183858;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ContosoUniversity-20140501183858.mdf" />
    
     </connectionStrings>
     <appSettings>
     <add key="webpages:Version" value="2.0.0.0" />
     <add key="webpages:Enabled" value="false" />
     <add key="PreserveLoginUrl" value="true" />
     <add key="ClientValidationEnabled" value="true" />
     <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    
     </appSettings>
     <system.web>

    Thanks

    Best Regards              

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 8, 2014 2:12 AM