将Web.Config应用程序设置存储在单独的文件中时,是否总是需要IIsreset? [英] Is IIsreset always neccessary when storing my Web.Config appsettings in a separate file?

查看:54
本文介绍了将Web.Config应用程序设置存储在单独的文件中时,是否总是需要IIsreset?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.Net应用程序,其中来自Web.Config xml的AppSettings节点存储在一个单独的文件中.

所以我的Web.Config包含以下内容:

<appSettings file="AppSettings.config" />

每当我在其中更改设置时,都必须进行iisreset才能强制执行更改.换句话说,在此文件中所做的更改不会像对Web.Config进行更改那样被检测到.

有人知道我如何使这些更改自动生效,就像Web.Config一样吗?

谢谢!

解决方案

针对其他答案.您可以更改machine.config使其包含appSettings的restartOnExternalChanges ="true"选项;但是,当您触摸任何外部应用程序设置文件时,这将导致所有Web应用程序重新启动. (此外,我认为这仅在您使用configSource ="file.name"而不是file ="file.name"时才有效.)

这是设计使然,导致应用程序重置的唯一方法是手动或通过脚本.

您可以在这里查看一个脚本,该脚本将在不重新启动iis的情况下重置您的应用程序:

http://weblogs.asp.net/jgalloway/archive/2006/06/01/Avoid-IISRESET-in-ASP.NET-applications-_2800_added-bonus_3A00_-ASPRESET_2900_.aspx

I've got an ASP.Net app in which my AppSettings node from the Web.Config xml is stored in a separate file.

So my Web.Config contains this:

<appSettings file="AppSettings.config" />

Whenever I change a setting in there I have to do an iisreset to force the changes to kick in. In other words, my changes in this file aren't detected the same way changes to the Web.Config is.

Does anyone know how I can make these changes take effect automatically, like it does with the Web.Config?

Thanks!

解决方案

Edit: In response to other answers. You can change the machine.config to include the restartOnExternalChanges="true" option for appSettings; however, this will cause ALL of your web applications to restart when you touch any of the external app settings files. (Also, I think this may only work when you use configSource="file.name" not file="file.name".)

This is by design and the only way to cause the application to reset is manually or via a script.

You can take a look here for a script which will reset your application without restarting iis:

http://weblogs.asp.net/jgalloway/archive/2006/06/01/Avoid-IISRESET-in-ASP.NET-applications-_2800_added-bonus_3A00_-ASPRESET_2900_.aspx

这篇关于将Web.Config应用程序设置存储在单独的文件中时,是否总是需要IIsreset?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆