If you run a WCF Web Service as an Application in IIS, but your application needs to store settings somewhere, the best place to keep them is in the web.config. MSDN recommends using the System.Web.Configuration.WebConfigurationManager class for interacting with the web.config file (or other web Application config files), but I found a much easier and faster way to do this. It's already built into Visual C# 2010 [Express]. Here's how to do it:
I'm sure there's a reason MSDN didn't mention this. Perhaps its much more efficient to use the WebConfigurationmanager class when there are lots of settings to reference. If anyone knows why this would be bad practice, let me know. |
Blog >