婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > asp.net計算每個頁面執(zhí)行時間的方法

asp.net計算每個頁面執(zhí)行時間的方法

熱門標簽:威海電銷 寧夏機器人電銷 河南語音外呼系統(tǒng)公司 400免費電話怎么辦理 t3出行地圖標注怎么做 400電話辦理最優(yōu)質(zhì) 外呼電銷機器人軟件 河北網(wǎng)絡回撥外呼系統(tǒng) 關于宗地圖標注技術規(guī)范

本文實例講述了asp.net計算每個頁面執(zhí)行時間的方法。分享給大家供大家參考。具體分析如下:

這里的asp.net代碼可實現(xiàn)計算每個頁面的執(zhí)行時間,無需要修改頁面的相關代碼,這段代碼會給所有的頁面統(tǒng)一加上執(zhí)行時間顯示

public class PerformanceMonitorModule : IHttpModule
{
 public void Init(HttpApplication context)
 {
  context.PreRequestHandlerExecute += delegate(object sender,EventArgs e)
  {
   //Set Page Timer Star
   HttpContext requestContext = ((HttpApplication)sender).Context;
   Stopwatch timer = new Stopwatch();
   requestContext.Items["Timer"] = timer;
   timer.Start();
   };
  context.PostRequestHandlerExecute += delegate(object sender, EventArgs e)
  {
   HttpContext httpContext = ((HttpApplication)sender).Context;
   HttpResponse response = httpContext.Response;
   Stopwatch timer = (Stopwatch)httpContext.Items["Timer"];
   timer.Stop();
   // Don't interfere with non-HTML responses
   if (response.ContentType == "text/html")
   {
    double seconds = (double)timer.ElapsedTicks / Stopwatch.Frequency;
    string result_time = string.Format("{0:F4} sec ", seconds);
    RenderQueriesToResponse(response,result_time);
   }
  };
 }
 void RenderQueriesToResponse(HttpResponse response, string result_time)
 {
  response.Write("div style=\"margin: 5px; background-color: #FFFF00\"");
  response.Write(string.Format("b>Page Generated in "+ result_time));
  response.Write("/div>");
 }
 public void Dispose() { /* Not needed */ }
}

希望本文所述對大家的asp.net程序設計有所幫助。

您可能感興趣的文章:
  • ASP.NET筆記之頁面跳轉(zhuǎn)、調(diào)試、form表單、viewstate、cookie的使用說明
  • ASP.net實現(xiàn)頁面跳轉(zhuǎn)的方法
  • ASP.NET 頁面中加添加用戶控件的寫法
  • 三步將Asp.Net頁面輸出到EXCEL里
  • 設置ASP.NET頁面的運行超時時間詳細到單個頁面及站點
  • asp.net截屏功能實現(xiàn)截取web頁面
  • ASP.Net頁面生成餅圖實例
  • 三種asp.net頁面跳轉(zhuǎn)的方法

標簽:淮北 池州 樂山 賀州 固原 咸寧 廣元 吉林

巨人網(wǎng)絡通訊聲明:本文標題《asp.net計算每個頁面執(zhí)行時間的方法》,本文關鍵詞  asp.net,計算,每個,頁面,執(zhí),;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp.net計算每個頁面執(zhí)行時間的方法》相關的同類信息!
  • 本頁收集關于asp.net計算每個頁面執(zhí)行時間的方法的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 汉源县| 长宁区| 唐河县| 宁晋县| 靖远县| 扎囊县| 兰考县| 平武县| 柏乡县| 库伦旗| 义马市| 收藏| 广宁县| 平利县| 嘉祥县| 达日县| 怀仁县| 福安市| 双桥区| 根河市| 喀什市| 泗阳县| 彩票| 砀山县| 河源市| 炎陵县| 湖南省| 武清区| 河曲县| 杨浦区| 红河县| 堆龙德庆县| 婺源县| 合山市| 巍山| 宜春市| 桐梓县| 阿瓦提县| 海丰县| 双辽市| 买车|