-1

我按照此处的设置说明https://miniprofiler.com/dotnet/AspDotNetCore并让 Mini Profiler 与我的 ASP.NET 核心 Web 应用程序一起工作。我将代码推送到我的暂存站点,现在可以看到每个请求的输出。

以前仅本地访问记录在这里https://miniprofiler.com/

using StackExchange.Profiling;
...    
protected void Application_BeginRequest()
{
    if (Request.IsLocal)
    {
        MiniProfiler.Start();
    } 
}

如何限制 miniprofiler 仅显示 ASP.NET 核心中的本地请求

4

1 回答 1

0

从文档中:

services.AddMiniProfiler(options =>
{
    // (Optional) To control authorization, you can use the Func<HttpRequest, bool> options:
    // (default is everyone can access profilers)
    options.ResultsAuthorize = request => CanAccessMiniProfiler(request);
    options.ResultsListAuthorize = request => CanAccessMiniProfiler(request);
}

你可以以任何你喜欢的方式实现它:

private bool CanAccessMiniProfiler(HttpRequest request)
{
    // Add your logic here, e.g. check for local requests and certain roles
}
于 2018-06-20T15:48:49.337 回答