0

I am trying to setup MiniProfiler to run in all of our environments instead of just on our local machines. It is my understanding that StackOverflow runs MiniProfiler in production without any issues. When I open my developer tools in Chrome and go to the network tab on StackOverflow's site, I do not see any posts being made to the following url:

mini-profiler-resources/results

When I look in the network tab on our site, I do see many posts to this URL. The code I am using in Global.cs is:

protected void Application_Start()
{
    MiniProfiler.Settings.Results_Authorize = IsUserAllowedToSeeMiniProfilerUI;
    MiniProfiler.Settings.Results_List_Authorize = IsUserAllowedToSeeMiniProfilerUI;
}

protected void Application_BeginRequest()
{
    MiniProfiler.Start();
}

protected void Application_EndRequest()
{
    MiniProfiler.Stop();
}

private static Boolean IsUserAllowedToSeeMiniProfilerUI(HttpRequest request)
{
    return request.IsLocal || request.RequestContext.HttpContext.User.IsInRole("Admin");
}

Am I doing something wrong here? The only thing I can think of it not starting the profiling session, but then it wouldn't be profiling users requests. The MiniProfiler UI is not showing up, so that part is working correctly, however all of the requests are still being made and the RenderIncludes method is loading the js code into the DOM.

Thanks!

Christopher Haws
  • 1,715
  • 21
  • 21
  • Are you accessing your site from its server or from your own machine ? – Guilherme Branco Stracini Mar 23 '17 at 03:31
  • It happens either way, locally on the server it is deployed on and also remotely. – Christopher Haws Mar 24 '17 at 22:34
  • Just remove the code to show the UI in the view (probably I'm your _Layout.cshtml), your code is right, but it's has not to do about showing or not the UI for any user, its just about allowing the user to access the results itself – Guilherme Branco Stracini Mar 27 '17 at 02:52
  • It seems weird that I would have to do that when none of the samples in the MiniProfiler repo have any kind of conditional logic around the `@MiniProfiler.RenderIncludes()` logic. – Christopher Haws Mar 27 '17 at 19:35
  • I think there's a mismatch here - Stack Overflow runs MiniProfiler for every request, but we don't expose it to users...so not seeing any POSTs is normal. Is that the confusion? I got a bit lost in the question admittedly. – Nick Craver Jun 11 '17 at 21:30
  • 1
    @NickCraver How are you preventing it from being exposed to end users? Are you wrapping the `@MiniProfiler.RenderIncludes()` call with some logic to only call it for SO admins or are you using `Global.cs` hooks for managing this (i.e `MiniProfiler.Settings.Results_Authorize` event)? When you say SO runs MiniProfiler for every request, do you mean every request for every user, or only admin users that can see the results? Thanks! :) – Christopher Haws Jun 22 '17 at 18:53

0 Answers0