把舊系統遷移到.Net Core 2.0 日記 (20) --使用MiniProfiler for .NET
阿新 • • 發佈:2019-02-22
chan change https master pro call highlight share asp
要查看頁面耗時,EFCore的性能.
- 安裝 MiniProfiler.AspNetCore.Mvc 還有 MiniProfiler.EntityFrameworkCore
Install-Package MiniProfiler.AspNetCore.Mvc
編輯Startup.cs
public void ConfigureServices(IServiceCollection services) { //EFCore性能監控 services.AddMiniProfiler().AddEntityFramework();... }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IMemoryCache cache)
{
app.UseMiniProfiler();
// The call to app.UseMiniProfiler must come before the call to app.UseMvc
app.UseMvc(routes =>
{
// ...
});
}
編輯 _ViewImports.cshtml
:
@using StackExchange.Profiling
@addTagHelper *, MiniProfiler.AspNetCore.Mvc
Add MiniProfiler to your master layout (Shared/_Layout.cshtml
by default):
<mini-profiler />
把舊系統遷移到.Net Core 2.0 日記 (20) --使用MiniProfiler for .NET