2

I am using Miniprofiler in an asp.net core2.0 application. Startup.cs

services.AddMiniProfiler(options => {
            options.RouteBasePath = "/profiler";
            (options.Storage as MemoryCacheStorage).CacheDuration = TimeSpan.FromMinutes(60);
            options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter();
            options.ResultsAuthorize = request => !Program.DisableProfilingResults;
        });

For each connection, I do:

DbConnection connection = new System.Data.SqlClient.SqlConnection(_connectionString);
            return new StackExchange.Profiling.Data.ProfiledDbConnection(connection, MiniProfiler.Current);

Examples are taken from here https://miniprofiler.com/dotnet/HowTo/ProfileSql. In outputting information, I see the loading of static content (js, css, etc.) including database queries, how can I disable this?

1 Answers1

4

Make sure you add the MiniProfiler middleware AFTER the StaticFiles middleware in your Startup.cs file:

public void Configure(IApplicationBuilder app) {
    app.UseFileServer();
    app.UseStaticFiles();
    app.UseMiniProfiler();
    app.UseMvc();
}

If that is not an option or doesn't solve your problem you can also configure MiniProfiler to ignore the paths where your static files are located:

public IServiceProvider ConfigureServices(IServiceCollection services) {
     services.AddMiniProfiler(options => {
         options.IgnoredPaths.Add("/js/");
         options.IgnoredPaths.Add("/css/");
     })
}
Peter Riesz
  • 3,091
  • 29
  • 33