2011-06-12 79 views
16

我试图让MVC迷你分析器使用webforms。MVC迷你分析器 - Web窗体 - 找不到/迷你分析器结果

NUGET
我已经安装了Nuget包。

PM> Install-Package MiniProfiler 


我有这个在我的网站的头部。

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
<%= MvcMiniProfiler.MiniProfiler.RenderIncludes() %> 

DAL
我用这一个功能作为一个POC内。这不是在Global.asax(我不如果那是必需的或不知道。)

profiler = MiniProfiler.Start(); 

using (profiler.Step("Im doing stuff")) 
{ 
    //do stuff here 
} 

MvcMiniProfiler.MiniProfiler.Stop(); 

结果
它使得我的网页上一个<div class="profiler-results left"></div>标签,但它是空的。

如果我看着铬控制台我看到一个404试图找到:http://example.com/mini-profiler-results?id=339d84a7-3898-429f-974b-64038462d59a&popup=1

问题
我错过了一步拿到/迷你探查,结果链接的工作?

回答
我标记为答案使我觉得这没有什么与我的配置做的(这是真的)的响应。我正在使用Umbraco 4.7.0。我不得不在我的web.config中将“〜/ mini-profiler-results”添加到umbracoReservedUrls和umbracoReservedPaths。

+0

参见http://stackoverflow.com/questions/15087101/miniprofiler-for-asp-net-web-site – 2017-03-27 20:39:20

回答

21

下页的工作只是伟大,我安装的NuGet包后:

<%@ Page Language="C#" %> 
<%@ Import Namespace="MvcMiniProfiler" %> 
<%@ Import Namespace="System.Threading" %> 

<script type="text/c#" runat="server"> 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     MiniProfiler.Start(); 
     using (MiniProfiler.Current.Step("I'm doing stuff")) 
     { 
      Thread.Sleep(300); 
     } 
     MiniProfiler.Stop(); 
    } 
</script> 

<!DOCTYPE html> 
<html> 
<head runat="server"> 
    <title></title> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
    <%= MiniProfiler.RenderIncludes() %> 
</head> 
<body> 
    <form id="Form1" runat="server"> 
     <div>Hello World</div> 
    </form> 
</body> 
</html> 
+8

快速更新最新版本,命名空间已从“MvcMiniProfiler”更改为“StackExchange.Profiling”,因此只需更改第二行,并且它都很好..... – 2012-10-21 10:49:44