asp.net效能

來源:互聯網
上載者:User

 1.關閉不必要的Session
<%@ Page EnableSessionState="flase"%>
2.關閉不必要的ViewState
<asp:DataGrid EnableViewState="false" runat="server">
如果頁面級
<%@ Page EnableViewState="false"%>
3.不要使用Exception控製程序流程
  Exception是很耗資源的
4.禁用VB和JScript動態資料類型
動態資料類型是要佔用大量的CPU已耗用時間
<%@ Page Language="VB" Strict="true"%>
5.使用預存程序的資料訪問
6.唯讀資料訪問不要使用DataSet(DataSet是中斷連線的,儲存再記憶體中,所以資源的消耗巨大)
 使用SqlDataReader代替DataSet
 SqlDataReader是read-only,forward-only
7.關閉ASP.NET的Debug模式,部署時是再web.config中取消Debug.
8.ASP.NET輸出緩衝
頁面緩衝:
<% OutputCache Duration=60 VaryByParam="None"%>
   Duration=延遲時間;
   VaryByParam=控制項id,例如VaryParam="TextBox1";
   切不可作無為的緩衝;
片斷緩衝 :VaryByControl
asp.net新的對象Cache於Application對象具有相同的範圍
Cache.Insert("MyData",Source,new CacheDependency(Server.MapPath("authors.xml")));
絕對到期
Cache.Insert("MyData",Source,null,DataTime.Now.AddHours(1),TimeSpan.Zero);
相對到期
Cache.Insert("Mydata",Source,null,DataTime,MaxValue,TimeSpan.FromMinutes(20));

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.