Reading settings from separate config file

前端 未结 2 1571
抹茶落季
抹茶落季 2020-12-09 22:50

My asp.net app has is using a web.config for common configuration. I also have a section that maps some data objects to connection strings, and that section is going to be c

2条回答
  •  星月不相逢
    2020-12-09 23:19

    In each section, you can define configSource, which can point to an external file path. Here's a simple example:

    
    
    

    Just make sure not to use .xml file extension since it can be viewed in a browser. .config will not be served by the web server.

    Because your config sections are still defined in the web.config (thus pointing to external files), you can access this information via the normal routes (WebConfigurationManager.AppSettings, WebConfigurationManager.GetSection, ConfigurationManager, or custom section handlers as needed)

提交回复
热议问题