views:

254

answers:

1

I'm writing a WPF application to help non-XML-savvy customers set up configuration files on a web server. web.config is one of these files. I have custom sections defined, but I've commented them out until I get the basics working.

In web.config, I have this:

  <appSettings>
    <add key="buffer" value="65536"/>
    <add key="updateInterval" value=""/>
  </appSettings>

Here's a snippet of how I'm reading web.config (I have already confirmed that web.config exists inside AppPath):

var vdm = new VirtualDirectoryMapping(AppPath, true);
var wcfm = new WebConfigurationFileMap();
wcfm.VirtualDirectories.Add("/", vdm);
WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");

However, WebConfigurationManager.AppSettings["buffer"] returns null. Any ideas?

A: 

Duhhhh. It's Monday morning. :-)

var config = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");

config.AppSettings["buffer"] works.

Matthew Cole