I am using ASP.NET Web API to read data from SQL Server. After publishing the API to IIS, I get this error:
The connection string property has not been initialized
C# code used to read connection string:
<code>string sqlDataSource = _configuration.GetConnectionString("Test_Server");
</code>
<code>string sqlDataSource = _configuration.GetConnectionString("Test_Server");
</code>
string sqlDataSource = _configuration.GetConnectionString("Test_Server");
Configured the connection strings in IIS 10.0, and here is my web.config
file:
<code><connectionStrings>
<remove name="LocalSqlServer" />
<add name="Test_Server"
connectionString="Server=ServerName;Database=DBName;User ID=myname;Password=mypassword" />
</connectionStrings>
</code>
<code><connectionStrings>
<remove name="LocalSqlServer" />
<add name="Test_Server"
connectionString="Server=ServerName;Database=DBName;User ID=myname;Password=mypassword" />
</connectionStrings>
</code>
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="Test_Server"
connectionString="Server=ServerName;Database=DBName;User ID=myname;Password=mypassword" />
</connectionStrings>
1