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

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x