Click here to Skip to main content
11,496,146 members (335 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: .NET1.0 .NET2.0 .NET3.0 C#3.0 , +
In my new project they have used one code like
string A = System.Configuration.ConfigurationManager.AppSettings["CheckPassword"];
What is the use of this code? why the are using this?
What could be the use of this code?
Posted 7-May-13 0:48am
Edited 7-May-13 0:55am
v2
Comments
Member 9514099 at 7-May-13 5:51am
   
From my understanding, it means that the developer has provided with a standard password value in app.config file.
In "string A = System.Configuration.ConfigurationManager.AppSettings["CheckPassword"];" they are trying to assign that value to a variable A.
Check your app.config file for "checkpassword"
There will be a web.config/app.config file existing on that application. Check that.

That is xml file usually contains all the configuartion information for the application.

You will find the key CheckPassword inside AppSettings tag under parent tag configuration inside that file something like below.

<configuration>
    <appSettings>
        <add key="CheckPassword" value="MyValue" />
    </appSettings>
</configuration>

We store some sensitive information in this manner as to avoid writing it many times whenever needed inside our application.
And if it needs to be changed, then we just need to change at that configuration file and the application will work as intact.

So, according to this hierarchy, you will access that value like below.
string A = System.Configuration.ConfigurationManager.AppSettings["CheckPassword"];
// So, value of A will be "MyValue"


Explore More

1. appSettings Element (General Settings Schema)[^]
Quote:
Contains custom application settings, such as file paths, XML Web service URLs, or any information that is stored in the.ini file for an application.

2. ASP.NET appSettings[^]
3. ASP.NET Configuration File Hierarchy and Inheritance[^]
4. ASP.NET Configuration Files[^]
  Permalink  
v2
Comments
Róhän Lêuvà at 7-May-13 6:24am
   
↑ed..!
Tadit Dash at 7-May-13 6:36am
   
Thanks Rohan...:)
My Part of answer
You ll get the value of CheckPassword from web.config or app.config.
  Permalink  
With this code you can read the variables of your program that is saved in the web.config or app.config.
you can access to it from all forms.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100