校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁(yè) > 知識(shí)庫(kù) > asp.net計(jì)算每個(gè)頁(yè)面執(zhí)行時(shí)間的方法

asp.net計(jì)算每個(gè)頁(yè)面執(zhí)行時(shí)間的方法

熱門標(biāo)簽:威海電銷 寧夏機(jī)器人電銷 河南語(yǔ)音外呼系統(tǒng)公司 400免費(fèi)電話怎么辦理 t3出行地圖標(biāo)注怎么做 400電話辦理最優(yōu)質(zhì) 外呼電銷機(jī)器人軟件 河北網(wǎng)絡(luò)回?fù)芡夂粝到y(tǒng) 關(guān)于宗地圖標(biāo)注技術(shù)規(guī)范

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

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

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 */ }
}

希望本文所述對(duì)大家的asp.net程序設(shè)計(jì)有所幫助。

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

標(biāo)簽:淮北 池州 樂(lè)山 賀州 固原 咸寧 廣元 吉林

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net計(jì)算每個(gè)頁(yè)面執(zhí)行時(shí)間的方法》,本文關(guān)鍵詞  asp.net,計(jì)算,每個(gè),頁(yè)面,執(zhí),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net計(jì)算每個(gè)頁(yè)面執(zhí)行時(shí)間的方法》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp.net計(jì)算每個(gè)頁(yè)面執(zhí)行時(shí)間的方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 栖霞市| 明星| 翁源县| 永宁县| 凤城市| 西青区| 绥芬河市| 交口县| 舒城县| 萨嘎县| 巴青县| 玉环县| 德清县| 尚义县| 宁河县| 临泽县| 常州市| 明水县| 山西省| 垫江县| 富平县| 阳泉市| 磐安县| 曲靖市| 平塘县| 隆尧县| 饶阳县| 南宁市| 凤山县| 特克斯县| 商水县| 梁河县| 额尔古纳市| 潼关县| 宜兰市| 广昌县| 克山县| 乐昌市| 陕西省| 曲麻莱县| 龙井市|