用户控件在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.

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

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....