Mini profiler doesn't display ajax request information?

I use the mini profiler in my asp.net MVC 3 application. I implemented the profiler using the mvc nuget package. Everything works fine for standard page requests. I get sql profile information.

However, ajax requests are not displayed at first. Just to confirm that the request completed without errors. I debugged this, and they conclude that they also return responses to 200 responses in the script.

The mini profiler request accompanying the ajax request is missing. When I then go to another page, that is, the standard page request will now be displayed, all the ajax requests made on the last page.

This is my mini profiler setup page in App_Start

public static class MiniProfilerPackage { public static void PreStart() { //Setup sql formatter MiniProfiler.Settings.SqlFormatter = new OracleFormatter(); //Make sure the MiniProfiler handles BeginRequest and EndRequest DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule)); //Setup profiler for Controllers via a Global ActionFilter GlobalFilters.Filters.Add(new ProfilingActionFilter()); //Settings MiniProfiler.Settings.PopupShowTimeWithChildren = true; MiniProfiler.Settings.PopupShowTrivial = false; //Ignore glimpse details in miniprofiler var ignored = MiniProfiler.Settings.IgnoredPaths.ToList(); ignored.Add("Glimpse.axd"); MiniProfiler.Settings.IgnoredPaths = ignored.ToArray(); } public static void PostStart() { // Intercept ViewEngines to profile all partial views and regular views. // If you prefer to insert your profiling blocks manually you can comment this out var copy = ViewEngines.Engines.ToList(); ViewEngines.Engines.Clear(); foreach (var item in copy) { ViewEngines.Engines.Add(new ProfilingViewEngine(item)); } } } public class MiniProfilerStartupModule : IHttpModule { public void Init(HttpApplication context) { context.BeginRequest += (sender, e) => { var request = ((HttpApplication)sender).Request; MiniProfiler.Start(); }; //Profiling abadened if user is not in the admin role context.PostAuthorizeRequest += (sender, e) => { if (!context.User.IsInRole("Admin")) MiniProfiler.Stop(discardResults: true); }; context.EndRequest += (sender, e) => { MiniProfiler.Stop(); }; } public void Dispose() { } } 

Is there some kind of configuration that is required or potential problems that I should be aware of?

+4
source share
2 answers

In the end, I realized that the JavaScript Miniprofiler block that is being added to the page should be below the jquery link.

My JavaScript link has been added at the end of the page for better performance.

But I left @ MvcMiniProfiler.MiniProfiler.RenderIncludes () in the page title. Moving it under a jQuery script ref at the bottom of the page fixed my problem.

+8
source

It just turned out that the same situation is repeated if

 $.ajaxSetup({ global: false }); 
0
source

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


All Articles