Accessing appSettings from multiple Web.config files

前端 未结 2 424
猫巷女王i
猫巷女王i 2021-01-12 10:17

I am designing an ASP.NET MVC4 Web App project. In the root of my project, I have the customary default Web.config file with my corresponding elements. In parti

相关标签:
2条回答
  • 2021-01-12 10:20

    Figured it out! To use a different config file, incorporate WebConfigurationmanager. So, to access the appSettings of ./Areas/PackageName/Web.config, simply use:

    var config = WebConfigurationManager.OpenWebConfiguration("~/Areas/PackageName");
    string dirE = config.AppSettings.Settings["dirEnabled"].Value;
    
    0 讨论(0)
  • 2021-01-12 10:36

    Try with

    <appSettings file="<Path_To_Second_Web.Config>">
       ...
    </appSettings >
    

    in your project's Web.config

    http://msdn.microsoft.com/en-us/library/aa903313(v=vs.71).aspx

    0 讨论(0)
提交回复
热议问题