Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

asp.net core miniprofiler

Install-Package MiniProfiler.AspNetCore.Mvc -IncludePrerelease
//Once installed, modify your startup.cs code like the following.

public void ConfigureServices(IServiceCollection services)
{
    services.AddMemoryCache();
    services.AddEntityFrameworkSqlite().AddDbContext<DatabaseContext>();
    services.AddMiniProfiler(options => options.RouteBasePath = "/profiler").AddEntityFramework();
    services.AddControllers();
}
//Next we need add the MiniProfiler middleware, you can do like this.

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.UseMiniProfiler();
    /* Code removed for brevity. */
}
//Next add the following two lines inside the <html> tag in the _Layout.cshtml file.

@using StackExchange.Profiling
@addTagHelper *, MiniProfiler.AspNetCore.Mvc
//You should also specify where in the web page the MiniProfiler window should be displayed, i.e., the render position. To do this, you can include the following statement inside the <body> tag.

<mini-profiler position="@RenderPosition.Right" max-traces="5" />
Source by miniprofiler.com #
 
PREVIOUS NEXT
Tagged: #core #miniprofiler
ADD COMMENT
Topic
Name
5+3 =