2013-02-26 43 views
11

enter image description here如何在asp.net網站(不適用於MVC)中使用miniprofiler? MVC有很多資源,但我找不到任何網站。Miniprofiler for ASP.NET網站

感謝Alex。現在它適用於asp.net網站。但我無法理解它顯示的內容。 我沒有在方法中寫任何代碼。看到下面的圖片。

代碼如下,我跑分析器。

protected void Page_Load(object sender, EventArgs e) 
{ 
    using (MiniProfiler.Current.Step("test")) 
    { 
     Page.Title = "12345"; 
    } 
} 

回答

23

miniprofiler.com

PM>安裝,包裝MiniProfiler

global.asax

using StackExchange.Profiling; 
...  
protected void Application_BeginRequest() 
{ 
    if (Request.IsLocal) 
    { 
     MiniProfiler.Start(); 
    } 
} 

protected void Application_EndRequest() 
{ 
    MiniProfiler.Stop(); 
} 
在母版頁

然後某處:

<%= StackExchange.Profiling.MiniProfiler.RenderIncludes() %> 

這應該足以啓動。

+0

感謝亞歷克斯,現在我可以看到分析器,但我不明白這一切意味着什麼。你能指導我嗎? 查看我編輯的問題附加的代碼和圖像。 – 2013-02-26 11:17:45

+1

@ChiragFanse:通過使用'MiniProfiler.Current.Step(「test」)'你正在創建一個名爲「test」的* profile步驟*。通常,您可以將一些*重邏輯*放入步驟中,然後查看這些步驟的統計信息。 – Alex 2013-02-26 12:13:19

+0

當我查看<%= StackExchange.Profiling.MiniProfiler.RenderIncludes()%>在瀏覽器中呈現的HTML中時,什麼都沒有出現。但沒有錯誤或任何東西。 – 2014-05-01 07:34:08