External AppSettings File NOT merging with web.config

前端 未结 4 2041
长发绾君心
长发绾君心 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:42

    I was able to confirm that the external app.config works with a simple project.

    app.Config (in same directory as web.config)

    
      
      
    
    

    web.config

    ...
      
        
        
      
    ...
    

    Default.aspx

    ...
    
    
        web: 
    app:
    override:
    ...

    Inside the Default.aspx.cs

        protected void Page_Load(object sender, EventArgs e)
        {
            lblWeb.Text = ConfigurationManager.AppSettings["testWebConfigString"];
            lblApp.Text = ConfigurationManager.AppSettings["testAppConfigString"];
            lblOverride.Text = ConfigurationManager.AppSettings["testOverrideString"];
        }
    

    The resulting page should have the following text:

    web: web config string exists!
    app: APP string exists!
    override: !!OVERRIDE string exists in app.config!
    

提交回复
热议问题