Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a app.config file that I have a url in and its listed as

C#
<appSettings>
     <add key="web" value="http://URL HERE"/>
  </appSettings>


then in a file I have

ChatMessengerService.Messenger messenger = new ChatMessengerService.Messenger();


messenger.Url = System.Configuration.ConfigurationManager.AppSettings["web"];
bool loginSucces = messenger.Login(username, sha1HashStr);


however its not reading but if I hardcoded the url it will work just fine

Any help would be nice.
Posted

Trye to write your appsettings in configuration secton like this
XML
<configuration>
  <appSettings>
    <add key="web" value="http://URL HERE" />
  </appSettings>
</configuration>

Then add the following reference
using System.Configuration;
And finally in your code section you have to write like this,
messenger.Url = ConfigurationManager.AppSettings["web"];
 
Share this answer
 
If you are using MVC, there are 2 web.config file available in it. One for Views and another for the whole solution. Kindly check in which web.config, you have added the app key. It should be solution's web.config for getting the value.
 
Share this answer
 

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