7

I keep reading that the new MVC avoids using System.Web by default as that used to add lots of extra stuff automatically.

Does that mean that in order to read the config file now in MVC5, one should use from System.Net instead?

Thanks...

2 Answers 2

13

It should be:

string key = System.Configuration.ConfigurationManager.AppSettings.Get("AppKey");

OR

string key = System.Configuration.ConfigurationManager.AppSettings["AppKey"];
Sign up to request clarification or add additional context in comments.

Comments

6

I read somewhere in a Microsoft example where they imported

using System.Configuration;

and then use the standard

ConfigurationManager.AppSettings["MyKey"]

Just thought to post this in case somebody has the same question/problem

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.