Stack Exchange MiniProfiler not showing profile window?

I installed the Stack Exchange MiniProfiler and the View Source shows that it displays the expected HTML. However, a small window with a detailed profile is not displayed in the corner - what could be wrong?

<script src="/v2/Scripts/jquery-1.6.1.min.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="/v2/mini-profiler-includes.css?v=1.7.0.0"> <script type="text/javascript" src="/v2/mini-profiler-yepnope.1.0.1.js"></script> <script type="text/javascript"> yepnope([ { test: window.jQuery, nope: '/v2/mini-profiler-jquery.1.6.1.js' }, { test: window.jQuery && window.jQuery.tmpl, nope: '/v2/mini-profiler-jquery.tmpl.beta1.js' }, { load: '/v2/mini-profiler-includes.js?v=1.7.0.0', complete: function() { jQuery(function() { MiniProfiler.init({ ids: ["025bbb91-9605-44b7-b33d-d8b196326dbc","2c74ce3e-8de6-4f8d-920a-e8708b22231b"], path: '/v2/', version: '1.7.0.0', renderPosition: 'left', showTrivial: false, showChildrenTime: false, maxTracesToShow: 15 }); }); } }]); </script> 

And in my Global.asax.cs file:

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

enter image description here

EDIT: thanks to Sam's input, I tracked the problem using my .ajaxSetup () method. When it is commented out, the profile window is displayed again. But I do not understand why this is the problem:

 $.ajaxSetup({ data: "{}", dataFilter: function (data) { var msg; if (data == "") { msg = data; } else if (typeof (JSON) !== 'undefined' && typeof (JSON.parse) === 'function') { msg = JSON.parse(data); } else { msg = eval('(' + data + ')'); } if (msg.hasOwnProperty('d')) { return msg.d; } else { return msg; } } }); 
+4
source share
2 answers

I assume the global dataFilter is interfering with MiniProfiler $.get() for jQuery template files. Calling JSON.parse() on an HTML snippet is bound to throw an error.

Since you are using the latest jQuery, optimized JSON parsing is not something you need to add manually. This functionality was included in the jQuery kernel in version 1.4.

So, the easiest way, try changing your global DataFilter to this:

 $.ajaxSetup({ data: "{}", dataFilter: function (msg) { if (msg.hasOwnProperty('d')) { return msg.d; } else { return msg; } } }); 

If this is not fixed, you might want to look at jQuery 1.5 converters instead of the global dataFilter, which will allow you to apply a similar dataFilter operation to the responses of a specific Content-Type. Some good examples are from the guy who was actually rewriting jQuery 1.5 AJAX here: http://encosia.com/jquery-1-5s-ajax-rewrite-and-asp-net-services-all-is-well/#comments

+2
source

This approach makes sense, maybe your filter distorts the results.

Adding a conditional condition that bypasses filtering if you see that the MiniProfiler JSON result should fix.

+2
source

Source: https://habr.com/ru/post/1369078/


All Articles