将MiniProfiler与.NetCore 3.1集成

编程入门 行业动态 更新时间:2024-10-26 12:34:24
本文介绍了将MiniProfiler与.NetCore 3.1集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要集成的MiniProfiler是WebApi或View/XX/results-index. WebApi已通过Bearer令牌进行了身份验证.我只希望Active Directory中的组用户可以看到结果,但我不明白.

I want to integrate MiniProfiler is a WebApi or View /XX/results-index. The WebApi is authenticated with Bearer Tokens. I only want Group Users in Active Directory can see the results, but I don't get it.

我在ServicesCollection中有以下代码:

I have this code in ServicesCollection:

services.AddMiniProfiler(options => { options.RouteBasePath = "/profiler"; options.ResultsAuthorizeAsync = async request => await GetAuthorization(request); }).AddEntityFramework(); private static async Task<bool> GetAuthorization(HttpRequest request) { // var user = request.HttpContext.User.Identity.Name; --> Is null return true; }

在启动时的配置方法"中:

In Configure Method in StartUp:

app.UseSwagger().UseSwaggerUI(options => { options.SwaggerEndpoint($"/swagger/v1/swagger.json", $"{env.ApplicationName} V1"); options.OAuthClientId("TestApiswaggerui"); options.OAuthAppName("TestApi Swagger UI"); options.IndexStream = () => GetType().GetTypeInfo().Assembly.GetManifestResourceStream( "TestApi.SwaggerMiniProfiler.html"); }) .UseMiniProfiler();

我想通过一些选项查看小型探查器信息:

I want to see mini profiler information through some options:

  • localhost:5050/profiler/results-index->显示名为的列表方法
  • localhost:5050/swagger/index.html->在同一页面中显示MiniProfiler

环境:

.NET Core version: 3.1 MiniProfiler version: MiniProfiler.AspNetCore.Mvc v.4.2.1 Operative system: Windows 10

推荐答案

我只想保留从活动目录中读取该组的跟踪信息的选项:

I just want to leave the option of having the traces read for that group from the active directory:

services.AddMiniProfiler(options => { // (Optional) Path to use for profiler URLs, default is /mini-profiler-resources options.RouteBasePath = "/profiler"; options.ColorScheme = StackExchange.Profiling.ColorScheme.Light; options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.BottomLeft; options.PopupShowTimeWithChildren = true; options.PopupShowTrivial = true; options.ShouldProfile = ShowProfile; options.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter(); options.ResultsAuthorize = request => request.HttpContext.User.IsInRole("S-INFORMATICA"); }) .AddEntityFramework();

更多推荐

将MiniProfiler与.NetCore 3.1集成

本文发布于:2023-11-01 12:14:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549303.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MiniProfiler   NetCore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!