Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Not able to read the value from App.config file

Not able to read the value from App.config file

Scheduled Pinned Locked Moved ASP.NET
securityhelpquestionworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kumar sudhir1
    wrote on last edited by
    #1

    I want to read the security key value from App.config file. Below is the procedure which I did : Create a new config file name as App.config In the App.config file: After that I did the following: System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); when i am debugging these, i find that the value of dimension is 0 which supposed to 1. since there is one key-value present in the App.config string key = (string)settingsReader.GetValue("SecurityKey", typeof(String)); Also it's throwing an exception stating “The key "SecurityKey" does not exist in the appSettings configuration section”.--which already present in the App.config. Also i tried with the second scenario: string key = System.Configuration.ConfigurationManager.AppSettings["SecurityKey"]; which giving me the key value null. Do i required to do some setting for reading the "SecurityKey" Value? Needs help! Thanks Sudhir Kumar Sudhir Kumar

    L 1 Reply Last reply
    0
    • K kumar sudhir1

      I want to read the security key value from App.config file. Below is the procedure which I did : Create a new config file name as App.config In the App.config file: After that I did the following: System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); when i am debugging these, i find that the value of dimension is 0 which supposed to 1. since there is one key-value present in the App.config string key = (string)settingsReader.GetValue("SecurityKey", typeof(String)); Also it's throwing an exception stating “The key "SecurityKey" does not exist in the appSettings configuration section”.--which already present in the App.config. Also i tried with the second scenario: string key = System.Configuration.ConfigurationManager.AppSettings["SecurityKey"]; which giving me the key value null. Do i required to do some setting for reading the "SecurityKey" Value? Needs help! Thanks Sudhir Kumar Sudhir Kumar

      L Offline
      L Offline
      Leon Segal
      wrote on last edited by
      #2

      If your web.config appSettings sections looks like the following: You can then use ConfigurationManager.AppSettings["SecurityKey"] to access it. Hope this helps. .leON.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups