Change connection string & reload app.config at run time

前端 未结 8 1391
广开言路
广开言路 2020-11-28 03:26

When I change the connection string using this code, it does not reload app.config at runtime. I expected it to reload similarly to how we reload app.conf

相关标签:
8条回答
  • 2020-11-28 04:01

    Yeah, when ASP.NET web.config gets updated, the whole application gets restarted which means the web.config gets reloaded.

    0 讨论(0)
  • 2020-11-28 04:06

    IIRC, the ConfigurationManager.RefreshSection requires a string parameter specifying the name of the Section to refresh :

    ConfigurationManager.RefreshSection("connectionStrings");
    

    I think that the ASP.NET application should automatically reload when the ConnectionStrings element is modified and the configuration does not need to be manually reloaded.

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