日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

性能提高小技巧

發布時間:2024/9/5 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 性能提高小技巧 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、避免不必要的執行操作
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();
????}
2、關閉不必要的Session狀態
<%@ Page EnableSessionState="false" %>
3、注意使用Server Control,不必要時可以不使用Server Control
不必要時可以關閉ViewState
<asp:datagrid EnableViewState="false“ runat="server"/>
<%@ Page EnableViewState="false" %>
4、不要用Exception控制程序流程
try?
{?
????result?
=?100?/?num;
}
catch?(Exception?e)?
{?
????result?
=?0;
}
if?(num?!=?0)?
????result?
=?100?/?num;
else
?????result?
=?0;?5、禁用VB和JScript動態數據類型
<%@ Page Language="VB" Strict="true" %>
6、使用存儲過程數據訪問
7、只讀數據訪問不要使用DataSet
使用SqlDataReader代替DataSet,SqlDataReader是read-only, forward-only
8、關閉ASP.NET的Debug模式
9、使用ASP.NET Output Cache緩沖數據
(1)ASP.NET輸出緩沖
頁面緩沖
<%@OutputCache%>
Duration
VaryByParam
片斷緩沖
VaryByControl
(2)數據緩沖
過期依賴條件
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));

轉載于:https://www.cnblogs.com/shanvenleo/archive/2006/03/03/342089.html

總結

以上是生活随笔為你收集整理的性能提高小技巧的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。