I have a connection string in my Web.Config file:
<configuration>
<connectionStrings>
<add name="Test" connectionString="MyConnString"/>
</connectionStrings>
</configuration>
And am trying to access it in my code like this:
string connectionString = ConfigurationManager.ConnectionStrings["Test"].ConnectionString;
Why am I receiving this error?
NullReferenceException: Object reference not set to an instance of an object.
ConfigurationManager.ConnectionStrings["Test"] is NULL but I can't figure out why.
I am using ASP.NET Core 3.1
I installed System.Configuration.Configuration version 6.0.0 using NuGet.
I have the correct using statement at the top of my code file: using System.Configuration;