Reputation: 287
I'm trying to connect Microsoft Azure's Database using my ASP.NET but my connection string throws a Null Reference Exception during runtime. The Connection String is correct (I got it off MSDN and added my account details to it). Here's the connection string in the Web.config file:
<configuration>
<appSettings>
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=MYACCOUNTNAME;AccountKey=MYACCOUNTKEY" />
</appSettings>
</configuration>
And I'm accessing the Connection string from the Code through this:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
The above code throws a Null Reference, pointing at the Connection String. What do you think is wrong? :)
Upvotes: 0
Views: 1447
Reputation: 24916
You are using appSettings
instead of connection strings. You need to change code to use appSettings
:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
Upvotes: 2