gpt4 book ai didi

c# - Swagger UI 隐藏 AspNetCore.Mvc.ProblemDetails 架构 .net 5 和 6

转载 作者:行者123 更新时间:2023-12-05 09:03:46 31 4
gpt4 key购买 nike

如何在 .net 5 和 .net 6 中隐藏 ProblemDetails 架构(见下文)。

enter image description here

最佳答案

对此的解决方案是在 Startup.cs 中使用 ConfigureApiBehaviorOptions SuppressMapClientErrors,如下所示:

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers().ConfigureApiBehaviorOptions(x => { x.SuppressMapClientErrors = true; });
...
}

关于c# - Swagger UI 隐藏 AspNetCore.Mvc.ProblemDetails 架构 .net 5 和 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69541795/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com