swagger .net核心API模棱两可的HTTP操作调试 [英] swagger .net core API ambiguous HTTP Action debugging

查看:342
本文介绍了swagger .net核心API模棱两可的HTTP操作调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用.net Core 2 API实现Swashbuckle/Swagger我现在在访问swagger.json时收到500错误:

Implementing Swashbuckle/Swagger with .net Core 2 API I am now receiving the 500 error when accessing swagger.json:

NotSupportedException:行为不明确的HTTP方法- EBisAPI.Controllers._class.HandleError(EBisAPI).动作需要 Swagger的显式HttpMethod绑定

NotSupportedException: Ambiguous HTTP method for action - EBisAPI.Controllers._class.HandleError (EBisAPI). Actions require an explicit HttpMethod binding for Swagger

我遍历了所有控制器,并在每个控制器的所有公共方法上看到了明确的路由.有没有一种方法可以确定哪个方法引发了模棱两可的路由错误?

I have gone through all the controllers and see explicit routing on all the public methods of each controller. Is there a way to determine which method is throwing the ambiguous routing error?

推荐答案

当在控制器中将方法声明为公共方法但没有REST属性时,可能会发生这种情况.将方法更改为保护"可能会解决该问题.

This can occur when a method is declared public in a controller, but without REST attributes. Changing the method to protected may address the issue.

我以前见过此错误,通常错误消息指向罪魁祸首: EBisAPI.Controllers._class.HandleError

I have seen this error before and usually the errormessage points to the culprit: EBisAPI.Controllers._class.HandleError

我想HandleError是您的基类中的public方法,对吗?将其更改为protected,然后重试.

I guess HandleError is a public method in your base class, right? Change it to protected and try again.

这篇关于swagger .net核心API模棱两可的HTTP操作调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆