我asp.net的项目使用www.example.com样板文件。我将devexpress版本从21.1.4更新到21.2.5,并制作了一个自定义WebDocumentViewerController。
public class CustomWebDocumentController :
WebDocumentViewerController
{
public
CustomWebDocumentController(IWebDocumentViewerMvcControllerService
controllerService) : base(controllerService)
{
}
}
我使用此代码删除www.example.com中的默认DocumentViewerControllerstartup.sc:
services.AddMvc()
.ConfigureApplicationPartManager(x =>
{
var parts = x.ApplicationParts;
var aspNetCoreReportingAssemblyName =
typeof(WebDocumentViewerController).Assembly.GetName().Name;
var reportingPart = parts.FirstOrDefault(part => part.Name
== aspNetCoreReportingAssemblyName);
if (reportingPart != null)
{
parts.Remove(reportingPart);
}
});
代码正在运行,但defualtcontroller仍在控制器列表中,并使swagger配置。
我该如何移除默认控制器?谢谢你的时间。
1条答案
按热度按时间o75abkj41#
弹出此"操作错误的不明确HTTP方法"的原因是此控制器"CustomWebDocumentController"在其顶部缺少HTTP操作装饰([HttpGet]、[HttpPost]等)。
简单地用"[ApiExplorerSettings(IgnoreApi = true)]"修饰控制器。这将最终导致整个控制器或单个操作从Swagger输出中省略。
来源:Exclude controllers methods from docs without using the Obsolete attribute