📜  asp.net core miniprofiler - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:51.705000             🧑  作者: Mango

代码示例1
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();
    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  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  tag.