我应该使用外部 Configuration.xml 文件还是仅使用 web.config?

发布于 2024-10-01 03:21:49 字数 229 浏览 2 评论 0原文

对于我的 Web 应用程序,我有几个启动配置值需要存储在配置 xml 文件中,并在 Web 启动时加载。我的问题是我应该使用外部 xml 还是只是将所有这些值放入 web.config 文件中?如果我使用外部 xml,那么我应该何时加载它以及应该将值保存到哪里(Application_Start 方法?保存到 Application['name']?)。当我更改这个 xml 文件时,我需要重新启动整个应用程序,对吗?

谢谢。

For my web application, I have several startup config values that need to be stored on a config xml file and will be loaded up when the web starts. My question is should I use an external xml or just put all those values into the web.config file? And if I use the external xml then when should I load it and where should I save the values to (Application_Start method? save to Application['name']?). And when I change this xml file, I need to restart the whole application right?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风筝在阴天搁浅。 2024-10-08 03:21:49

在不了解更多细节的情况下,我说使用 web.config。这就是我们拥有它的原因:)

当您编辑 web.config 时,更改将在下一个请求时生效。

编辑以解决评论

如果您的配置文件变得臃肿,您可以将部分移动到外部文件。

<configuration>
   <appSettings configSource="appSettings.config" />   
   <connectionStrings configSource="connectionStrings.config" />
   <system.web>    
      <pages configSource="pages.config" />
      <httpHandlers configSource="httphandlers.config">
   </system.web>    
</configuration>

Without knowing more details, I say use the web.config. That is why we have it :)

When you edit web.config, the change will be picked up on the next request.

edit to address the comment

If your config file is getting bloated, you can move sections to an external file.

<configuration>
   <appSettings configSource="appSettings.config" />   
   <connectionStrings configSource="connectionStrings.config" />
   <system.web>    
      <pages configSource="pages.config" />
      <httpHandlers configSource="httphandlers.config">
   </system.web>    
</configuration>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文