External AppSettings File NOT merging with web.config

前端 未结 4 2039
长发绾君心
长发绾君心 2021-01-12 00:31

In my app, I have a web.config file with an appSettings section. The appSettings section contains a number of keys that the app uses. The appSettings section also contains

4条回答
  •  心在旅途
    2021-01-12 00:44

    You can access multiple config files by using WebConfigurationmanager method. add namespace:

    using System.Web.Configuration;
    

    So, to access the appSettings of

    ../SomeProjectFolder/Environment/Web.config, you can do:

    var config = WebConfigurationManager.OpenWebConfiguration("~/SomeProjectFolder/Environment/");
    string username = config.AppSettings.Settings["username"].Value;
    

    Hope this helps.

提交回复
热议问题