Click here to Skip to main content
16,004,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,im working on webapis i want the code for GET in C# that read from web.config and actually there is some data in web.config

What I have tried:

 public List<Test> Index(int Id)
        {
            List<Test> url= (List<Test>)new 
           string url= WebConfigurationManager.AppSettings["Rulz_"]
;
            return url;

        }
Posted
Updated 16-Nov-17 16:36pm

1 solution

try
string url = System.Configuration.ConfigurationManager.AppSettings["Rulz_"];

have tested with both the WebConfigurationManager Class [^] and ConfigurationManager Class (System.Configuration)[^] it gives the correct result, Make sure the appsettings node in the Web.Config contains the key "Rulz_"

<appSettings>
  <add key="Rulz_" value="aaaa"/>
</appSettings>
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900