修改 web.config 时如何防止 ASP.NET 应用程序重新启动? [英] How to prevent an ASP.NET application restarting when the web.config is modified?

查看:36
本文介绍了修改 web.config 时如何防止 ASP.NET 应用程序重新启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 ApplicationHost.CreateApplicationHost 方法托管 ASP.NET 运行时.当我在应用程序运行时修改 web.config 时,我看到很多第一次机会 ThreadAbortException 被抛出.这是在我的应用程序崩溃之前.我假设这是因为运行时检测到配置更改并想要重新启动.

I'm hosting the ASP.NET runtime via the ApplicationHost.CreateApplicationHost method. When I modify the web.config while the application is running, i see lots of first chance ThreadAbortExceptions thrown. This is right before my application comes crashing down. I'm assuming this is because the runtime has detected changes to the configuration and wants to restart.

这对我们来说并不是真正支持的场景,所以我希望我可以关闭自动重新加载.

This isn't really a supported scenario for us, so i'd prefer if I could just switch off the automatic reloading.

有人知道怎么做吗?

推荐答案

据我所知,无法禁用此行为,对 webconfig 的更改会强制重新启动应用程序.

更新:实际上是可能的,有很多方法,有据可查,如在本答案中解释*

Update: it is actually possible, there are a number of methods, well documented, as explained in this answer*

原答案:

这里有一个类似的问题,仅供参考.我找到了可能有帮助的其他信息.

There is a similar question here just for other reference. I found additional info that may be helpful.

配置更改导致重启应用领域的
更改为Web.config 中的配置设置文件间接导致应用程序域重新启动.这种行为设计使然.您可以选择使用 configSource 属性参考外部配置文件当 a 时不会导致重新启动做出改变.想要查询更多的信息,请参阅 一般属性中的 configSource由节元素继承.

来自这篇 MSDN 文章

* 免责声明:我写了另一个答案,通常不会自我引用,但发现它足够相关,可以在这篇文章发布 8 年后链接到这里,这真的很不一样:解决方案非常简单通过单击 IIS 前端,并且自 ASP.NET 1.0 以来存在变通方法.

这篇关于修改 web.config 时如何防止 ASP.NET 应用程序重新启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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