How does the browser read the Connection String in Web.config?

-1

I am using a connection string which works fine with my local database, but it does not work with my host's database. This is my code in web.config file

     <connectionString>
    <add name="DatabaseContext" providerName="System.Data.SqlClient" connectionString="Server=emre;Database=TestVeriTabani;Integrated Security=true;" />
  </connectionString> 

I get this error

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the configuration data for the page is invalid.

Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not determined yet
Error Code 0x80070032
Configuration Error Section notification is missing, so 'connectionString' configuration section cannot be read
Configuration File \\? \ C: \ Users \ m\ source \ repos \ DatabaseTest \ DatabaseTest \ web.config
Requested URL http: // localhost: 50902 /
Physical Path
Logon Method Not determined yet
Logon User Not set yet
Request Tracking Directory C: \ Users \ emre\ Documents \ IISExpress \ TraceLogFiles \

Configuration Source:
   12: </configSections>
   13: <connectionString>
   14: <add name = "DatabaseContext" providerName = "System.Data.SqlClient" connectionString = "Server = emre; Database = TestDataBase; Integrated Security = true;" />

More Information:
This error occurs when there is a problem reading the Web server or Web application's configuration file. In some cases, more information about the cause of this error can be found in the event logs.
If you see the text "A duplicate 'system.web.extensions / scripting / scriptResourceHandler' section defined" in the browser, this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, go to the Settings node to fix this problem by setting the .NET Framework version to ".NET 2". You can also remove additional sections in the web.config file.
asp.net
.net
sql-server
asp.net-mvc
asked on Stack Overflow Nov 12, 2020 by emrecevik • edited Nov 12, 2020 by jarlh

1 Answer

-1

Use this connectionString and replace server_name, UserName, DB_name and Passwor with real data.

  <connectionString>
    <add name="DatabaseContext" providerName="System.Data.SqlClient" connectionString="Server=server_name ;Initial Catalog=DB_name;Persist Security Info=False;User ID=UserName;Password=PAssword;MultipleActiveResultSets=true;Encrypt=True;Connection Timeout=30;" />
  </connectionString> 
answered on Stack Overflow Nov 12, 2020 by Aleksandar M.

User contributions licensed under CC BY-SA 3.0