SharePoint、VirtualPathProviders 和应用程序重新启动

发布于 2024-08-08 12:05:11 字数 1247 浏览 6 评论 0原文

鉴于卸载动态编译的程序集(以回收内存)的唯一方法是卸载应用程序域,那么 SharePoint 如何依赖 VirtualPathProviders(尤其是母版页和页面布局)而不会遇到此限制?

可以通过各种设置延迟重启,但当母版页和页面布局频繁更新和发布时并不能完全避免,对吗?

(缺乏这方面的信息是否归因于它是一个在发布模式中不常见的更理论的限制?您个人是否注意到母版页或布局的更改率导致应用程序不稳定?SharePoint 是否应该发出警告?)

任何 CMS -利用动态 WebForms(默认情况下包括 MVC 视图)的能力很容易受到变化率不稳定的影响,对吗?

关于非编译页面的更新:

非编译页面 在ASP.NET 2.0中,编译模型得到了显着的重构和扩展。站点预编译可能是最流行且呼声最高的新功能。另一个非常有趣的功能是无编译页面。它们是特殊的页面,永远不会被编译。那么免编译页面的最终目的是什么,它和静态HTML页面有什么区别呢? 首先,通过将 @Page 指令上的 CompilationMode 属性设置为 Never 来创建一个非编译页面。当请求非编译页面时,不会创建页面程序集并将其保留到磁盘。相反,页面构建器组件的实例缓存在内存中,并用于为每个请求创建页面输出。页面构建器是一个特殊的组件,它支持页面解析器构建页面控制树。当编译打开时,控制树用于获取要编译的类。当编译关闭时,控制树用于获取标记。不用说,如果您想赋予程序员将自己的代码附加到页面的能力,那么类是必要的。非编译页面由服务器控件和文字组成,但根本不包含任何代码。

非编译页面并不适合所有应用程序。它们专门为提高具有数千个页面的大型网站的可扩展性而设计。非编译页面不能绑定到代码文件,也不能包含服务器端块。非编译页面中允许的唯一可执行代码是 $ 表达式。无编译页面有两个主要好处。在像 SharePoint 这样的安全环境中,非编译页面可以防止开发人员编写可能存在错误的代码,这些代码可能会给托管环境带来问题,甚至将其破坏。在大型基于内容的网站中,免编译页面避免了编译数千个页面的需要。

参考文献:

1http://haacked.com/archive/2009/04/ 22/scripted-db-views.aspx

Given that the only way to unload dynamically compiled assemblies (to reclaim memory) is to unload the app domain, how does SharePoint rely on VirtualPathProviders, for master pages and page layouts in particular, without bumping into this limitation?

The restart can be delayed through various settings but not avoided completely when master pages and page layouts are updated and published frequently, correct?

(Is the lack of info on this attributed to it being a more theoretical limit that's not common in publishing patterns? Have you personally noticed the rate of changes to master pages or layouts causing app instability? Should SharePoint come with a warning?)

Any CMS-esque capability that leverages dynamic WebForms (including, by default, MVC views) is susceptible to rate-of-change instability, correct?

Update on No-Compile Pages:

No-compile pages
In ASP.NET 2.0, the compilation model has been significantly refactored and extended. Site precompilation is perhaps the most popular and loudly requested of the new features. Another quite interesting feature is no-compile pages. They are special pages that just never get compiled. So what’s the ultimate purpose of no-compile pages, and what’s the difference between them and static HTML pages?
To start off, you create a no-compile page by setting the CompilationMode attribute on the @Page directive to Never. When a no-compile page is requested, no page assembly is created and persisted to disk. Instead, an instance of the page builder component is cached in memory and used to create the page output for each and every request. The page builder is a special component that supports the page parser in building the page control tree. When compilation is turned on, the control tree is used to obtain a class to compile. When compilation is off, the control tree is used to obtain markup. Needless to say, classes are necessary if you want to give programmers the power of attaching their own code to the page. No-compile pages are made of server controls and literals but contain no code at all.

No-compile pages are not for every application. They are exclusively designed for improving the scalability on very large web sites with thousands of pages. No-compile pages can’t be bound to a code file and can’t contain a server-side block. The only executable piece of code allowed in a no-compile page are $-expressions. There are two main benefits out of no-compile pages. In a secure environment like SharePoint, no-compile pages prevent developers from writing potentially buggy code that can cause problems to the hosting environment and even tear it down. In a large content-based web site, no-compile pages avoid the need to compile thousands of pages.

References:

1
http://haacked.com/archive/2009/04/22/scripted-db-views.aspx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

逆流 2024-08-15 12:05:11

首先要注意的是,自定义页面(可能是母版页或页面布局)始终存储在数据库中。

页面请求周期与普通 ASP.net 版本的不同之处在于 SPVirtualPathProvider 路由请求的方式。一旦找到,就会发出对自定义页面的请求(与文件系统上的未自定义页面相反,并受通常的 ASP.net 页面编译模式的约束),页面的代码将从数据库中提取,并传递给 ASP .net 运行时,并以“无编译模式”进行解析。

以下是发出自定义页面请求时的流程的可视化呈现:

替代文字

赞美 Shivprasad Koirala

这里也很好地描述了 ASP.net 的无编译模式< /a>

无编译页面:

无编译页面可实现改进
扩展具有数千个的大型站点
页数,因为 windows 有页数限制
加载到应用程序中的 DLL 和性能
当您达到此限制时就会降级。放
<%@ 页面 CompilationMode="自动"
%>编译指令
有条件地获得缩放
不受代码限制的好处。
您还可以将 CompilationMode 设置为
“从不”以阻止页面出现
正在编译中。你可以这样设置上的属性部分
在 Web.config 中应用到所有页面
一个应用程序。未编译的页面将
当包含用户时抛出错误
代码。

因此,这基本上解决了您提到的关于由于实时发生的多个自定义而卸载/加载应用程序域时过多的应用程序重置的问题(任何构建在 ASP.net 运行时上的 CMS 都必须解决的问题)。

除此之外;当以这种方式存储自定义内容时,您可以“免费”获得 SQL Server 的多用户功能和可扩展性;与文件系统方法相反,文件系统方法需要额外的努力来管理锁定。

First thing to note is that customized pages (Could be masterpages or page layouts) are always stored in the database.

The page request cycle differs from the vanilla ASP.net version in the way SPVirtualPathProvider routes requests. Once it's found the request is made for a customized page (as opposed to an uncustomized page sitting on the file system, and subject to the usual ASP.net page compilation mode) the page's code is pulled from the database, handed off to the ASP.net runtime, and parsed in "no-compile mode."

Here's a visual rendition of the process when a request for a customized page is made:

alt text

Compliments Shivprasad Koirala

Here is also good description of ASP.net's no compile mode

No Compile Pages:

No Compile Pages enables improved
scaling for large sites with 1000s of
pages, as windows has limit on number
of DLLs loaded into an app and perf
degrades as you hit this limit. Set
the <%@ Page CompilationMode="Auto"
%> directive to compile
conditionally to obtain the scaling
benefits without limitations on code.
You can also set CompilationMode to
"Never" to prevent the page from ever
being compiled. You can set this
property on the <pages/> section
in Web.config to apply to all pages in
an application. A no-compile page will
throw an error when it contains user
code.

So this basically addresses the issue you mentioned with regards to excessive application resets when unloading/loading an app domain due to multiple customizations happening in real-time (an issue any CMS built on the ASP.net runtime would have to address).

On top of this; you get the multiuser capabilities and scalability of SQL Server "for free" when storing customized content in this way; as opposed to a file system approach which would necessitate extra effort to manage locking.

挽清梦 2024-08-15 12:05:11

找到了对此的一个很好的解释1:

作为开发人员,您的第一反应
对此可能会质疑为什么
自定义页面处理在
无编译模式。你的直觉可能
告诉你编译的页面运行
比不编译页面更快。然而,
无编译页面可以更高效
并且在某些方面更具可扩展性
场景。尤其是在
一个大型 WSS 环境,其中
定制页数可达
成数千或数十
数千。

无需编译的页面可以加载到内存中然后卸载
以一种不可能的方式
编译页面,因为 .NET
框架并不真正支持
卸载程序集 DLL 的概念
从记忆中。最接近的等价物
将回收当前的
Windows 进程或当前的 .NET
应用程序域。然而,这种类型的
回收涉及卸载所有
从内存中汇编 DLL,而不仅仅是
那些还没有的程序集DLL
最近使用过。此外,.NET
框架设定了上限
可以的汇编 DLL 的数量
加载到 .NET AppDomain 中。

无编译页面提供更高级别的可扩展性,因为
他们不需要加载新的
将 DLL 或托管类组装到
记忆。相反,处理
无编译页面涉及加载
控制树进入内存。 WSS可以
管理内存使用情况
相关的控制树
定制页面更高效
因为它们没有被编译成
汇编 DLL。例如,一旦 WSS
已完成定制加工
page,它可以卸载页面的控件
树为其他树释放内存
目的。此外,不编译
页面消除了浏览的需要
编译过程,其中
实际上提供了更快的响应
首次访问页面的时间。

他们的关键要点很简单,可以卸载未编译的页面(可以卸载关联的页面构建器),而这对于已编译的页面来说是不可能的。但从本质上讲,这是一种可扩展性措施(在此模型下可以处理更多页面),而不是性能增强(在初始设置后,已编译页面的性能应该比未编译页面的性能更好)。

1 -
http://chiragrdarji.wordpress.com/2007/10/12/page-ghosting-unghosting-and-effect-of-pageghosting-on-performance-in-sharepoint-2007/

Found a nice explanation of this 1:

As a developer, your initial reaction
to this might be to question why
customized pages are processed in
no-compile mode. Your instincts likely
tell you that compiled pages run
faster than no-compile pages. However,
no-compile pages can be more efficient
and more scalable in certain
scenarios. This is especially true in
a large WSS environment where the
number of customized pages can reach
into the thousands or tens of
thousands.

No-compile pages can be loaded into memory and then unloaded
in a manner that is not possible for
compiled pages because the .NET
Framework doesn’t really support the
concept of unloading an assembly DLL
from memory. The closest equivalent
would be to recycle the current
Windows process or the current .NET
AppDomain. However, this type of
recycling involves unloading all
assembly DLLs from memory, not just
those assembly DLLs that haven’t been
used recently. Furthermore, the .NET
Framework places an upper limit on the
number of assembly DLLs that can be
loaded into a .NET AppDomain.

No-compile pages provide higher levels of scalability because
they do not require loading new
assembly DLLs or managed classes into
memory. Instead, the processing of
no-compile pages involves loading
control trees into memory. WSS can
manage the memory usage for the
control trees associated with
customized pages more efficiently
because they are not compiled into
assembly DLLs. For example, once WSS
has finished processing a customized
page, it can unload the page’s control
tree to free up memory for other
purposes. Furthermore, no-compile
pages eliminate the need to go through
the compilation process, which
actually provides faster response
times for pages upon first access.

They key takeway is simply that no-compile pages can be unloaded (the associated page builder can be unloaded), which isn't possible with compiled pages. At its core though, this is a scalability measure (more pages can be handled under this model) and not a performance enhancement (after initial setup, compiled pages should perform better than their non-compiled counterparts).

1 -
http://chiragrdarji.wordpress.com/2007/10/12/page-ghosting-unghosting-and-effect-of-pageghosting-on-performance-in-sharepoint-2007/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文