Is web.config or app.config cached in memory

后端 未结 3 1167
青春惊慌失措
青春惊慌失措 2021-01-01 23:58

if it is cached, what happens if I use multiple web.config in multi-level folders

3条回答
  •  半阙折子戏
    2021-01-02 00:44

    OK, so ya'll are missing a KEY feature in the Web.Config file's area.

    Yes, web.config is cached and changing contents of the file will restart your web app. And, all your connected users will not be happy, too, because they'll need to "reconnect" a-new, possibly losing desired information.

    So, use an EXTERNAL custom file for your AppSettings, as follows:

    
    

    Then, in the file MyCustom_AppSettings.config file, you have your settings, as such this example has:

    
    
      
      
    
      
      
      
      
    
    

    Now, if you need to add, change, or remove an AppSetting, when you change it in this file the change is nearly instant in your web-app BUT (and here's the BEST part), your app DOES NOT RESTART!

    Everything stays kosher except those settings you've added/modified/removed in the external .config file.

    And, yes, the same thing can done for the section as follows:

    
    

    and the file MyCustomApp_ConnectionStrings.config has all the connection strings you need. Change a connection string in the external .config file and it starts getting used right away and with no web-app restart.

    The configSource setting(s) are great when you need to deploy to development, testing, and production on different boxes and need settings pertinent to that given box/environment.

    So, now ya know (something that's been around for 7+ years).

    It's That Simple. Really.

    KC

提交回复
热议问题