在 IIS7 中重新启动网站以“刷新”的最佳方法温莎城堡配置
我有一系列托管在 IIS7 中的 ASP.NET 网站。我使用 Castle Windsor 进行依赖注入,配置数据保存在 XML 文件中。
我想嘿,这很酷,我只需编辑文件即可切换到界面的不同实现。我意识到,因为 Castle Windsor 在实例化容器时解析 XML 配置,所以我需要以某种方式重新启动网站才能“重置”Castle Windsor。
这并不像我想象的那么简单。我尝试右键单击 IIS 中的站点并选择“重新启动”,但这不会切换实现。奇怪的是,如果我“停止”该网站,它就不再工作,但再次启动它,它会像以前一样继续运行。
我猜重新启动应用程序池会起作用,但由于这也会影响其他网站,我不想这样做。
谁能建议一种在不影响其他网站的情况下完全重新启动应用程序的方法?
I have a series of ASP.NET websites hosted in IIS7. I use Castle Windsor for dependency injection, and the configuration data is held in XML files.
I thought hey, this is cool, I can just edit the files to switch to different implementations of my interfaces. I realised that because Castle Windsor parses the XML config when the container is instantiated, I would need to restart the website somehow in order to 'reset' Castle Windsor.
This is not as straightforward as I thought. I have tried right clicking the site in IIS and choosing 'Restart', but this doesn't switch implementations. Weird, if I 'stop' the website, it no longer works, but start it again and it continues exactly as before.
I'm guessing restarting the app pool would work but since this would affect other websites too I don't want to do this.
Can anyone suggest a way to completely restart the app without affecting other websites?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以在城堡配置文件和更新事件上设置 FileSystemWatcher,您可以调用
这将导致 Application_end ,以便下一个请求时您的 Web 应用程序/ AppDomain 将重新启动
You can set a FileSystemWatcher on castle config file(s) and on update event, you can call
that will cause Application_end on so on next coming request your webapplication/ AppDomain will restart
您可以将有问题的网站放入单独的应用程序池中并重新启动它(考虑到您对重新启动应用程序池的猜测)。
这样您就不会删除其他有问题的网站。
You could place the website in question into a seperate App Pool and restart it (given your guess about restarting the app pool).
This way you wouldn't take down the other sites in question.
嗯嗯。打开并保存 web.config 就可以了。有人知道有什么更优雅的吗? :)
Hmmmm. Opening and saving web.config does the trick. Anyone know anything a little more elegant? :)
如果这些设置与
web.config
位于不同的文件中,则更改其设置不会触发应用程序重新启动。除非可以通过某种方式通知温莎城堡在运行时刷新其设置,否则重新加载配置的唯一方法就是“触摸”
web.config
文件。If these settings are in a different file from
web.config
then altering their settings won't trigger an application restart.Unless Castle Windsor can be notified in some way to refresh its settings at runtime then the only was to reload the config is to "touch" the
web.config
file.