相关疑难解决方法(0)

MiniProfiler没有出现在asp.net MVC上

我把它添加到我的Global.asax.cs:

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

protected void Application_EndRequest()
{
    MiniProfiler.Stop();
}
Run Code Online (Sandbox Code Playgroud)

我补充道

@MiniProfiler.RenderIncludes()
Run Code Online (Sandbox Code Playgroud)

</body>在_Layout.cshtml 中的标记下方.

在我的控制器中我正在使用:

 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);
                } …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc profiler mvc-mini-profiler

23
推荐指数
1
解决办法
6272
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

mvc-mini-profiler ×1

profiler ×1