0

Here is my appsettings

<appSettings>
    <add key="webpages:Enabled" value="true" />
    <add key="K1" value="Debendra Dash"/>
  </appSettings>

Here is how i am trying to read in my controller:

string x = System.Configuration.ConfigurationManager.AppSettings["K1"];

And am getting null always. Here is my web.config.

enter image description here

3
  • 2
    make sure you include web.config in the project. Commented May 1, 2018 at 4:52
  • yes as you can see web config is in the project only. Commented May 1, 2018 at 5:10
  • 1
    right click in the file and click include in project Commented May 1, 2018 at 5:21

1 Answer 1

2

Your code is correct. Try a couple of things

  1. See if you're editing the correct Web.config.
  2. Try using WebConfigurationManager instead of ConfigurationManager
Sign up to request clarification or add additional context in comments.

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.