Where to place connection string in web.config

jason

My web.config looks like this :

<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>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
  </system.web>
  <runtime>

When I add my connection string just below <configuration> I get an error saying that only one <configSections> element is allowed. Where should I put my connection string?

huysentruitw

Just place it inside <configuration> right after </configSections> f.e.

<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>
    <connectionStrings>
        <add name="DefaultConnection" connectionString="blablabla" providerName="System.Data.SqlClient" />
    </connectionStrings>    
    <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    </appSettings>
    <system.web>
        <compilation debug="true" targetFramework="4.5.1" />
        <httpRuntime targetFramework="4.5.1" />
    </system.web>
    ...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

where to write the connection string ? in app.config or in web.config?

From Dev

When encrypting web.config connection string, where is the key stored?

From Dev

web.config connection string not set Context?

From Dev

Windows application + master web config + connection string

From Dev

Where to place <httpProtocol> in IIS Server web.config file

From Dev

EF 6 not using connection string in Web.config

From Dev

why i need to define the connection string in web config file

From Dev

Entity Framework Can't Find Connection String in Web.config

From Dev

Avoid giving server connection string in web.config

From Dev

Asp .net Web config file connection string with secured

From Dev

How to add CommandTimeout to connection string in web.config

From Dev

web.config connection string to different database server

From Dev

Encrypt the connection String in ASP.NET Web Config

From Dev

web.config connection string changing when published

From Dev

What is the point of Encrypt connection string in web.config?

From Dev

web.config connection string changing when published

From Dev

Programatically changing the connection string in web.config file

From Dev

Create DataTable from SQL Connection String in Web.config file

From Dev

Connection string has been loaded from Web.Config instead of App.Config

From Dev

Where is the proper place to add a method to handle SQL Connection String in ASP.NET WebAPI

From Dev

Where is the proper place to add a method to handle SQL Connection String in ASP.NET WebAPI

From Dev

Where to place the web admin folder?

From Dev

Where is my connection string?

From Dev

ASP.NET connection string to local SQL Server database, using web.config

From Dev

How to get only the provider connection string from Web.Config in EF setup?

From Dev

ASP.NET 5/EF7 connection string in web.config?

From Dev

Using connection string in Web.config when enabling code-first migrations

From Dev

how to add new connection string in web.config run time programatically in asp.net?

From Dev

Using web.config (asp.net, vb) to hold database connection string

Related Related

  1. 1

    where to write the connection string ? in app.config or in web.config?

  2. 2

    When encrypting web.config connection string, where is the key stored?

  3. 3

    web.config connection string not set Context?

  4. 4

    Windows application + master web config + connection string

  5. 5

    Where to place <httpProtocol> in IIS Server web.config file

  6. 6

    EF 6 not using connection string in Web.config

  7. 7

    why i need to define the connection string in web config file

  8. 8

    Entity Framework Can't Find Connection String in Web.config

  9. 9

    Avoid giving server connection string in web.config

  10. 10

    Asp .net Web config file connection string with secured

  11. 11

    How to add CommandTimeout to connection string in web.config

  12. 12

    web.config connection string to different database server

  13. 13

    Encrypt the connection String in ASP.NET Web Config

  14. 14

    web.config connection string changing when published

  15. 15

    What is the point of Encrypt connection string in web.config?

  16. 16

    web.config connection string changing when published

  17. 17

    Programatically changing the connection string in web.config file

  18. 18

    Create DataTable from SQL Connection String in Web.config file

  19. 19

    Connection string has been loaded from Web.Config instead of App.Config

  20. 20

    Where is the proper place to add a method to handle SQL Connection String in ASP.NET WebAPI

  21. 21

    Where is the proper place to add a method to handle SQL Connection String in ASP.NET WebAPI

  22. 22

    Where to place the web admin folder?

  23. 23

    Where is my connection string?

  24. 24

    ASP.NET connection string to local SQL Server database, using web.config

  25. 25

    How to get only the provider connection string from Web.Config in EF setup?

  26. 26

    ASP.NET 5/EF7 connection string in web.config?

  27. 27

    Using connection string in Web.config when enabling code-first migrations

  28. 28

    how to add new connection string in web.config run time programatically in asp.net?

  29. 29

    Using web.config (asp.net, vb) to hold database connection string

HotTag

Archive