ASP.NET 页面请求阶段...
在页面请求阶段(页面生命周期之前),ASP.NET 如何确定页面是否需要 1) 首次解析和编译,还是 2) 由于某个原因而需要重新解析和编译标记更改(假设“允许此预编译站点可更新”= true)或程序集更改?我可以做出一些相当安全的假设,但是有人确切地知道 ASP.NET 是如何做出这些决定的吗?
ASP.NET 页面生命周期: http://msdn.microsoft.com/en-us/library/ms178472.aspx
编辑: 因此,“第一次”被确定为 ASP.NET 网站的第一个资源请求; sooooooo,这不是“第一次”请求时需要解析和编译什么页面或资源(单数)的问题,而是 ASP.NET 第一次解析和编译任何页面的所有内容或请求资源。 “重新解析和重新编译”以一种看似“惰性”的方式发生:当对动态编译的文件进行更改时,这会使该文件先前编译的缓存版本无效;这会触发重新编译它和所有受影响的资源下一次请求代码 - 根据所做的更改,所有文件的 1-n 可能都需要重新编译。
感谢 @Mass 提供的链接
During the Page Request stage (prior to the Page life cycle), how does ASP.NET determine whether or not the Page needs to be 1) parsed and compiled for the first time or 2) re-parsed and re-compiled due to a markup change (assuming "Allow this precompiled site to be updatable" = true) or assembly change? I can make some pretty safe assumptions, but does anyone know exactly how ASP.NET makes these determinations?
The ASP.NET Page Life Cycle:
http://msdn.microsoft.com/en-us/library/ms178472.aspx
EDIT: So, "first time" is determined as the very first resource request off the ASP.NET web site; soooooo, it's not a question of what Page or resource (singular) needs to be parsed and compiled the "first time" it is requested, rather ASP.NET parses and compiles EVERYTHING the FIRST TIME ANY Page or resource is requested. "Reparse and recompile" occurs in what appears to be a "lazy" fashion: when a change to a dynamically compiled file takes place, this invalidates the previously compiled, cached version of that file; this triggers recompilation of it and all effected resources THE NEXT TIME THE CODE IS REQUESTED - depending on the change made, 1-n to all files may have to be recompiled.
Thanks @Mass for the link
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在以下链接中找到所需的所有答案:
在第一个请求时进行编译
在更改
编译输出
时重新编译http://msdn.microsoft.com/en-us/library/ms366723.aspx
you can find all the answers you need at the link below:
Compiling on First Request
Recompiling on Change
Compilation Output
http://msdn.microsoft.com/en-us/library/ms366723.aspx
关于第二点(“由于标记更改而重新解析和重新编译”):
有一个由 HTTP 运行时启动的文件系统监视器。您可能想使用 Reflector 探索
HttpRuntime.StartMonitoringDirectoryRenamesAndBinDirectory()
方法。下的
FCNMode
注册表项设置影响监视受HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET (x86)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\ASP.NET (x64)
Regarding the second point ("re-parsed and re-compiled due to a markup change"):
There is a filesystem monitor started by the HTTP runtime. You may want to explore the
HttpRuntime.StartMonitoringDirectoryRenamesAndBinDirectory()
method using the Reflector.Monitoring is affected by the
FCNMode
registry key setting underHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET (x86)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\ASP.NET (x64)