You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在类库中使用Asp.Net Core 7.0的AddProblemDetails扩展?

解决Asp.Net Core 7.0 AddProblemDetails扩展引用问题

要在类库中使用AddProblemDetails扩展方法,你需要安装**Microsoft.AspNetCore.Diagnostics**这个NuGet包——它是包含该扩展方法的核心依赖包。

需要注意的点:

  • 安装完成后,代码里要引入命名空间:using Microsoft.AspNetCore.Diagnostics;
  • 由于AddProblemDetails是IServiceCollection的扩展方法,你之前添加的Microsoft.Extensions.DependencyInjection包是必要的,不用移除。

你之前安装的Microsoft.AspNetCore.Http.Extensions并不包含这个扩展方法,所以无法找到对应的定义。

内容的提问来源于stack exchange,提问作者Ruslan Muradasilov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 11:31:41