IIS 重新编译 ASP NET 网站
我正在与一位朋友讨论当您将新文件放入虚拟目录中时 IIS 会做什么。
他告诉我,当您将文件放入网站中的任何位置时,IIS 会重新编译整个网站,我认为当您将文件放入 Bins 文件夹中时,就会发生(如果发生的话)。
之所以有这样的对话,是因为公司的一个网站用来上传文件,但是文件保存在我们网站的一个名为“Letters”的文件夹中,我的朋友说每次有人上传文件IIS都会重新编译整个网站。 他说得对吗?
I was talking with a friend about what IIS does when you put a new file inside a virtual directory.
He told me that IIS recompile the entire website when you put a file anywhere in the website, I think it just happens (if happen) when you put a file inside your Bins folder.
The conversation comes because a website in the company is use to upload files but the files are save inside a folder name "Letters" in our website, my friend says that every time someone upload a file IIS will recompile the entire website. Is he correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
很容易测试。 开始观察 Web 服务器上的 JIT 编译计数器...浏览器,然后将文件放入其中以查看计数器显示。
Easy enough to test. Start watching the JIT compile counters on the web server... Browser around, then drop a file in it to see the counters show.
回收应用程序池。 在 powershell 中:
这将强制代码重新编译。
Recycle the application pool. In powershell:
This will force code to recompile.
machine.config 中有一个设置 numRecompilesBeforeApprestart,它指示应用程序重新启动之前可能发生的文件更改数量。 默认值为 15。
在非生产环境中,我通常将其设置得更高,这样您就可以动态修改 aspx 页面,而不会导致整个应用程序重新启动。
这可能就是你朋友所说的。
There is a setting in the machine.config numRecompilesBeforeApprestart which indicates the number of file changes that can occurr before the application will restart. The default is 15.
In non production environments, I usually set this much higher so you can modify aspx pages on the fly without causing the entire app to restart.
This might be what your friend is talking about.
绝对取决于您的版本,因为:
还有一个新的修补程序可以让您优化编译,从而减少 IIS 重新编译的频率,但我不确定具体时间。
我认为过去如果您不导航到新标记(而是导航到另一个标记文件),则新标记不会触发重新编译,并且 bin/dll/程序集文件将始终触发。
Definitely depends on your version because:
There's also a new hotfix that lets you optimize compilation so IIS recompiles less often, but I'm not sure when exactly.
I THINK it used to be that new markup won't trigger a recompile if you don't navigate to it (and instead navigate to another markup file), and bin/dll/assembly files will always trigger.
我认为 ASP.NET 仅在 bin 程序集、App_Code 或 global.asax 更改时重新启动并重新编译整个站点。
请参阅 这篇博文了解优化 ASP.NET 编译行为的新标志的详细信息。
将文件添加到虚拟目录中的文件夹不应导致重新编译(除非该文件夹是“bin”或“app_code”!)
I think ASP.NET only re-starts and re-compiles the whole site when bin assemblies, App_Code or global.asax are changed.
See this blog post for details of a new flag to optimize ASP.NET compilation behavior.
Adding files to a folder within the virtual directory should not lead to a re-compile (unless the folder is 'bin' or 'app_code'!)
仅当您添加需要编译的代码时它才会重新编译。 即向App_Code 添加新类。 当您仅将图像或文本文件保存到网站时,它不会重新编译。
It only recompiles when you add code that needs to be compiled. I.e. adding new classes to App_Code. It doesnt recompile when you simply save an image or text file to the website.