I have the following in my web.config:
<configuration>
<connectionStrings>
<add name="strConDev" connectionString="Data Source=dbSource;Initial Catalog=CatalogInitial;User Id =DEFAULT; Password=PASSWORD" />
</connectionStrings>
</configuration>
I am trying to retrieve the connection string in my global.asa in the Application_Start method with the following code:
var con = ConfigurationManager.ConnectionStrings["strConDev"];
string strConn = con.ConnectionString;
However, this is always returning a null value to con. What am I doing wrong here? This is the syntax I was able to find online.
The syntax all appears correct. A couple things you can try:
<connectionStrings>or you may not have added elements into the correct sections