用户控件在asp.net和Performance中

前端之家收集整理的这篇文章主要介绍了用户控件在asp.net和Performance中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
asp.net中的UserControls是否会降低性能.

MasterPage有自己的生命周期
Page有自己的生命周期和
UserControls有自己的生命周期.

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

解决方法

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

但是,如果您正在讨论优化到处理器周期,我猜他们不会因为一切都被编译成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相关文章