MiniProfiler没有出现在asp.net MVC起来 [英] MiniProfiler not showing up on asp.net MVC
本文介绍了MiniProfiler没有出现在asp.net MVC起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我说这对我的Global.asax.cs:
保护无效的Application_BeginRequest()
{
如果(Request.IsLocal)
{
MiniProfiler.Start();
}
}保护无效Application_EndRequest()
{
MiniProfiler.Stop();
}
我添加
@ MiniProfiler.RenderIncludes()
在&LT以下; / BODY>以_Layout.cshtml
标签
在我的控制器中我使用:
公共类HomeController的:控制器
{
公众的ActionResult指数()
{
VAR探查= MiniProfiler.Current; //它的确定,如果这是空
使用(profiler.Step(设置页面标题))
{
ViewBag.Title =主页;
}
使用(profiler.Step(做复杂的东西))
{
使用(profiler.Step(步骤A))
{//更有趣的东西在这里
Thread.sleep代码(100);
}
使用(profiler.Step(步骤B))
{ // 和这里
Thread.sleep代码(250);
}
} 返回视图(〜/查看/主页/ Index.cshtml);
}
}
但没有什么是展示我的页面上了,没有轮廓框。
在做查看源代码code,我只看到这一点:
<脚本异步类型=文/ JavaScript的ID =微型分析器SRC =/迷你探查资源/ includes.js V = xwYPDDH1blvqmxgsBweNC ++ H7CFU3KGQ + zFcVlJPsXw =数据版本=xwYPDDH1blvqmxgsBweNC ++ H7CFU3KGQ + zFcVlJPsXw =数据路径=/迷你探查资源/数据流-ID =6d24704e-3003-44f8-9965-437c6275d639数据IDS =8ec2c718-4375-4d3f-9b69-4092e534143e,6d24704e-3003-44f8-9965-437c6275d639数据位=左的数据平凡=false的数据儿=false的数据-MAX-痕迹= 15数据控件=false的数据授权=真正的数据切换,快捷=ALT + P数据开始隐藏=false的>< / SCRIPT>
解决方案
在你的web.config,补充一点:
< system.webServer>
...
<&处理GT;
<添加名称=MiniProfiler路径=迷你探查资源/ *动词=*TYPE =System.Web.Routing.UrlRoutingModule= resourceType为未指定preCondition =integratedMode/&GT ;
...
< /处理器>
...
如果你想要一些甜蜜的MVC操作分析(无关你的问题),加入这一行的Application_Start
在Global.asax.cs中:
GlobalFilters.Filters.Add(新StackExchange.Profiling.MVCHelpers.ProfilingActionFilter());
I added this to my Global.asax.cs:
protected void Application_BeginRequest()
{
if (Request.IsLocal)
{
MiniProfiler.Start();
}
}
protected void Application_EndRequest()
{
MiniProfiler.Stop();
}
I added
@MiniProfiler.RenderIncludes()
just below the </body>
tag in _Layout.cshtml.
In my controller I'm using:
public class HomeController : Controller
{
public ActionResult Index()
{
var profiler = MiniProfiler.Current; // it's ok if this is null
using (profiler.Step("Set page title"))
{
ViewBag.Title = "Home Page";
}
using (profiler.Step("Doing complex stuff"))
{
using (profiler.Step("Step A"))
{ // something more interesting here
Thread.Sleep(100);
}
using (profiler.Step("Step B"))
{ // and here
Thread.Sleep(250);
}
}
return View("~/Views/Home/Index.cshtml");
}
}
But nothing is showing up on my page, no profile box.
When doing viewing the source code I only see this:
<script async type="text/javascript" id="mini-profiler" src="/mini-profiler-resources/includes.js?v=xwYPDDH1blvqmxgsBweNC++H7CFU3KGQ+zFcVlJPsXw=" data-version="xwYPDDH1blvqmxgsBweNC++H7CFU3KGQ+zFcVlJPsXw=" data-path="/mini-profiler-resources/" data-current-id="6d24704e-3003-44f8-9965-437c6275d639" data-ids="8ec2c718-4375-4d3f-9b69-4092e534143e,6d24704e-3003-44f8-9965-437c6275d639" data-position="left" data-trivial="false" data-children="false" data-max-traces="15" data-controls="false" data-authorized="true" data-toggle-shortcut="Alt+P" data-start-hidden="false"></script>
解决方案
In your web.config, add this:
<system.webServer>
...
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
...
</handlers>
...
If you want some sweet MVC Action profiling (unrelated to your problem), add this line to Application_Start
in Global.asax.cs:
GlobalFilters.Filters.Add(new StackExchange.Profiling.MVCHelpers.ProfilingActionFilter());
这篇关于MiniProfiler没有出现在asp.net MVC起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文