gpt4 book ai didi

asp.net - ASP.NET 中的用户控件和性能

转载 作者:行者123 更新时间:2023-12-02 15:31:35 25 4
gpt4 key购买 nike

asp.net 中的 UserControls 是否会降低性能。

MasterPage有自己的生命周期页面有自己的生命周期UserControls 有自己的生命周期。

UserControls有助于划分工作负载并且易于维护,但是UserControls是否会降低asp.net应用程序的性能

最佳答案

我从未见过它们降低性能,除非你做了一些愚蠢的事情,比如让每个用户控件负责它自己的数据库查找,然后将它们绑定(bind)在中继器或类似的东西中。如果您使用常识,它们不应显着降低性能。

但是,如果您谈论的是处理器周期的优化,我猜他们不会,因为所有内容都是如何编译为 MSIL,然后编译为机器代码,所以我猜编译器可以对其进行整理并处理用户控件与直接在页面上拥有所有组成控件没有什么不同。
编辑 - 添加

This article争论他们如何能够真正提高性能。有趣的。

In addition to their reusability and flexibility, Web user controls can take advantage of the ASP.NET caching engine to implement what is referred to as “fragment caching.” Essentially, fragment caching allows a Web developer to control the HTML caching of individual controls on a page, including setting the duration and caching various versions of the control based on query string, control properties, browser type, and even custom strings. The ability to cache only portions of pages is powerful since a portion of a page will often access relatively static data stored in a relational database or accessed through an XML Web service, while other portions of the same page manipulate dynamic data. For these static portions, creating a Web user control and setting caching options greatly reduces the number of database round trips, thereby increasing performance. In most instances, using ASP.NET caching judiciously is the single biggest performance improvement that can be made.

好问题。我再次学到了一些新东西。谢谢。

关于asp.net - ASP.NET 中的用户控件和性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3454746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com