forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMiniProfilerSetup.cs
More file actions
30 lines (27 loc) · 1.08 KB
/
MiniProfilerSetup.cs
File metadata and controls
30 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Microsoft.Extensions.DependencyInjection;
using System;
namespace Blog.Core.Extensions
{
/// <summary>
/// MiniProfiler 启动服务
/// </summary>
public static class MiniProfilerSetup
{
public static void AddMiniProfilerSetup(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
// 3.x使用MiniProfiler,必须要注册MemoryCache服务
services.AddMiniProfiler(options =>
{
options.RouteBasePath = "/profiler";
//(options.Storage as MemoryCacheStorage).CacheDuration = TimeSpan.FromMinutes(10);
options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.Left;
options.PopupShowTimeWithChildren = true;
// 可以增加权限
//options.ResultsAuthorize = request => request.HttpContext.User.IsInRole("Admin");
//options.UserIdProvider = request => request.HttpContext.User.Identity.Name;
}
);
}
}
}