ASP.NET性能提高的技巧
来源:互联网 发布:淘宝千人千面怎么设置 编辑:程序博客网 时间:2024/05/01 15:48
避免不必要的执行操作
Page_Load 和 IsPostBack
void Page_Load(Object sender, EventArgs e) {
// ...set up a connection and command here...
if (!Page.IsPostBack) {
String query = "select * from Authors where FirstName like '%JUSTIN%'";
myCommand.Fill(ds, "Authors");
myDataGrid.DataBind();
}
}
void Button_Click(Object sender, EventArgs e) {
String query = "select * from Authors where FirstName like '%BRAD%'";
myCommand.Fill(ds, "Authors");
myDataGrid.DataBind();
}
关闭不必要的Session状态
<%@ Page EnableSessionState="false" %>
注意使用Server Control
不必要时可以不使用Server Control
不必要时可以关闭ViewState
<asp:datagrid EnableViewState="false“ runat="server"/>
<%@ Page EnableViewState="false" %>
不要用Exception控制程序流程
try {
result = 100 / num;
}
catch (Exception e) {
result = 0;
}
if (num != 0)
result = 100 / num;
else
result = 0;
禁用VB和JScript动态数据类型
<%@ Page Language="VB" Strict="true" %>
使用存储过程数据访问
只读数据访问不要使用DataSet
使用SqlDataReader代替DataSet
SqlDataReader是read-only, forward-only
关闭ASP.NET的Debug模式
使用ASP.NET Output Cache缓冲数据
页面缓冲
<%@OutputCache%>
Duration
VaryByParam
片断缓冲
VaryByControl
数据缓冲
过期依赖条件
Cache.Insert("MyData", Source, new CacheDependency(Server.MapPath("authors.xml")));
Cache.Insert("MyData", Source, null,
DateTime.Now.AddHours(1), TimeSpan.Zero);
Cache.Insert("MyData", Source, null, DateTime.MaxValue,
TimeSpan.FromMinutes(20));
- ASP.NET性能提高的技巧
- 提高asp.net性能的技巧
- 提高ASP.NET性能的技巧
- 转帖 提高asp.net性能的十大技巧
- 有关提高ASP.NET性能的一些技巧
- 提高asp.net 的性能
- 提高ASP.net的性能
- asp提高首页性能的一个技巧
- asp提高首页性能的一个技巧
- asp.net性能的技巧
- asp.net性能的技巧
- asp.net性能的技巧
- asp.net性能的技巧
- asp.net性能的技巧
- asp.net性能的技巧
- asp.net性能的技巧
- asp.net性能的技巧
- asp.net性能的技巧
- mp3的自动连续播放以及探测是否可以播放、并对可以播放的结果进行保存
- 给25岁前的男人的忠告
- 关于指针泄漏
- Tomcat配置技巧Top 10 (转贴)
- 关于Myeclipse的一些问题
- ASP.NET性能提高的技巧
- XML缩进输出,最简单的方法!
- os loader引导多系统实战
- [NOTE] UML构成 - Jan 1, 2005
- 在Eclipse中用myEclipse进行开发
- 用Eclipse MyEclipse WebLogic8.1开发第一个Web程序
- Tomcat 4.1配置和使用
- 【转载】我与TOMCAT不得不说的二三事
- 在JavaScript中使用Java