Why might I not be getting any results from MiniProfiler?
Asked Answered
H

1

7

I can't seem to get any results from MiniProfiler.

I can see the XHR POST to /mini-profiler-resources/results returning a 404. The chrome request inspector gives me a standard server 404 page.

enter image description here

A GET on the same URL also returns a 404, but there is a message saying that "no results were found for the specified id" (I did add the id in the querystring).

When I look at /mini-profiler-resources/results-index it just gives me an empty table with the field headings in - name, started, sql, duration, etc.

I've tried a few things - details below - at this stage I am at a loss as to what I can try next. Any pointers or suggestions for debugging this problem would be much appreciated.


Installed Packages:

  • MiniProfiler (v3.2.0.157)
  • MiniProfiler.EF6 (v3.0.11)
  • MiniProfiler.MVC4 (v3.0.11)

Where MVC4 also caters for MVC5. Which this project is.


Relevant Code:

    protected void Application_Start()
    {
        MiniProfilerEF6.Initialize();
        MiniProfiler.Settings.Results_List_Authorize = IsUserAllowedToSeeMiniProfilerUI;
        MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue;
        Database.SetInitializer<ApplicationDbContext>(null);
        GlobalFilters.Filters.Add(new ProfilingActionFilter());
        var copy = ViewEngines.Engines.ToList();
        ViewEngines.Engines.Clear();
        foreach (var item in copy)
        {
            ViewEngines.Engines.Add(new ProfilingViewEngine(item));
        }
    }


    protected void Application_BeginRequest(Object source, EventArgs e)
    {
        if (Request.IsLocal)
        {
            // this IS being hit
            MiniProfiler.Start();
        }
    }


    protected void Applicaton_EndRequest()
    {
        MiniProfiler.Stop(discardResults: false);
    }


    private bool IsUserAllowedToSeeMiniProfilerUI(HttpRequest httpRequest)
    {
        return true;
    }

In HomeController.cs:

[AllowAnonymous]
public ActionResult Index()
{
    var profiler = MiniProfiler.Current;
    using (profiler.Step("Doing complex stuff"))
    {
        using (profiler.Step("Step A"))
        {
            ViewBag.Title = "Home Page";
        }
        using (profiler.Step("Step B"))
        { 
            Thread.Sleep(250);
        }
    }

    return View();
}

And in MasterLayout.cshtml:

@using StackExchange.Profiling; 

... 

@MiniProfiler.RenderIncludes()

I've Tried:

I have set discardResults to false, like this:

    protected void Applicaton_EndRequest()
    {
        MiniProfiler.Stop(discardResults: false);
    }

I can confirm that MiniProfiler.Start() IS getting hit when the page loads.


I can also confirm that the mini-profiler-resources/ route IS being found (using Haack's Route Debugger)


I have the following item in the <handlers> section of web.config, and it is in the correct section (e.g. this guy mistakenly put it in the ELMAH config ).

  <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />

I have set all my output caching to 1 second.


I was using a custom applicationhost.config file to test on a custom url.

I tried removing the custom url bindings and just using the standard localhost:51347.

I also tried putting the snippet below into applicationhost.config instead of the standard web.config.

<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />

In applicationhost.config I tried changing

<section name="handlers" overrideModeDefault="Deny" />

to

<section name="handlers" overrideModeDefault="Allow" />


I've added the following into application_start:

MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue;


As recommended in this answer, I have tried uninstalling all related packages and reinstalling them in this order:

  • MiniProfiler
  • MiniProfiler.MVC4
  • MiniProfiler.EF6

Update

9 days on, the bounty expired and still no joy :(

If anybody reading this in the future has ideas / suggestions, I'd really like to hear them. MiniProfiler is such a great tool and I'm disappointed that I haven't been able to get it working on this occasion.

If I do find the answer myself, I'll post it.

Housecoat answered 10/8, 2017 at 0:9 Comment(9)
What querying technology are you using? EF? Dapper? Raw ASP.Net? Something else?Gaivn
I'm using EF6.0Housecoat
Have you installed the MiniProfiler.EF6 Nuget package?Gaivn
Yeah I've installed MiniProfiler (v3.2.0.157), MiniProfiler.EF6 (v3.0.11) and MiniProfiler.MVC4 (v3.0.11). Where MVC4 also caters for MVC5. Which this project is.Housecoat
And you've run MiniProfilerEF6.Initialize() in Application_Start I presume?Gaivn
Yeah I have. Sorry ErikE, I should have put all this in the question. Doing this now.Housecoat
What is ProfilingActionFilter and ProfilingViewEngine doing?Multicolored
They're part of the MiniProfiler.MVC4 package - they automatically profile controllers / views, without needing to wrap them in profiling "step" syntax. Seen in action here: samsaffron.com/archive/2011/07/25/…Housecoat
Check your web.config for a duff runtime > assemblyBinding > dependentAssembly entry for MiniProfiler, specifically one where the redirect is pointing at the wrong version, i.e. not the version that you've got installed. I've seen this cause oddities for MVC before but can't remember exactly what - I think it was having a redirect pointing to an older version than was presentSven
R
1

After running into the same issue I found the answer here which worked fine. http://www.mukeshkumar.net/articles/mvc/performance-test-with-miniprofiler-in-asp-net-mvc

If you get an error after running application with MiniProfiler.Mvc4 or MiniProfiler.Mvc3 which state “/mini-profiler-resources/includes.js 404 not found” then simply add the following line of code in Web.Config inside web server section.

<system.webServer>
    <handlers>
      <add name="MiniProfiler" path="mini-profiler-resources/*"
               verb="*" type="System.Web.Routing.UrlRoutingModule"
               resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>   
</system.webServer>
Ruvolo answered 31/7, 2018 at 8:55 Comment(1)
Thanks for the answer. This is one of the things I tried, but it didn't help my situation.Housecoat

© 2022 - 2024 — McMap. All rights reserved.