我有ASP.NET MVC应用程序,它包含一些文件夹,当应用程序在IIS中运行时,这些文件可以实时更改。
当我更改某些带有 .resx (没有代码生成)和 .xml (带有自定义内容)等扩展名的文件时,我的应用程序池会刷新,而我不会想要这种行为,但是如果我改变 .cshtml ,那么游泳池就不会刷新。
当我在App_Data文件夹中提到“有问题”文件时,该池将不会刷新,但也许还有其他文件夹的解决方案。
例如,如果我的应用程序中有这样的文件夹结构:
App_Code
App_Data
- file1.resx // when its content changes the pool DOESN'T get refreshed
- files2.xml // when its content changes the pool DOESN'T get refreshed
- files3.cshtml // when its content changes the pool DOESN'T get refreshed
CustomFolder
- App_LocalResources
-- file1.resx // when its content changes the pool gets refreshed
-- files2.xml // when its content changes the pool gets refreshed
-- files3.cshtml // when its content changes the pool DOESN'T get refreshed
如果某些特定文件或文件类型发生更改,如何防止IIS应用程序池刷新?
感谢您的帮助。
答案 0 :(得分:1)
我认为App_Data
是一个特殊的目录,在应用程序重启/重新加载时会被忽略,因为很多动态/变化的内容都可以在那里结束。
从MSDN了解resx
个文件:
.resx(基于XML的资源格式)文件被转换为公共语言运行时二进制.resources文件,这些文件可以嵌入到运行时二进制可执行文件中或编译成附属程序集。
由此,我认为应用程序正在重新启动,因为resx
文件是在运行时编译的。
我认为没有办法阻止这种行为。关于How to prevent an ASP.NET application restarting when the web.config is modified?有一些想法,但我没有尝试过任何这些想法。
答案 1 :(得分:0)
找到解决方案。 当 .resx 文件发生更改时,应用池回收的问题位于App_LocalResources文件夹中。我将这个文件夹中的所有文件移动到一个名为Resources的新文件夹(与App_Data非常相似,因为它不是系统文件夹)。
新文件夹结构如下所示:
App_Code
App_Data
- ...
CustomFolder
Resources
file1.resx
files2.xml
files3.cshtml