网上看了很多关于此异常的解决方案,但是大多数都是不能用的,今天把正确的解决方案记录下来,以帮助需要的人

问题:有些接口没有设置HttpPost或HttpGet,非接口设置访问权限为private,控制台可以看到报错位置为UserController.Info

接口错误示例:
public object Get()
{
MongoDbContext dbContext = new MongoDbContext();
return new {
API = true,
Database = dbContext.Status()
};
}

接口正确示例:

[HttpGet]
public object Get()
{
MongoDbContext dbContext = new MongoDbContext();
return new {
API = true,
Database = dbContext.Status()
};
}

非接口(方法)示例:(访问权限设置成private,protected)

        private DateTime SecondsToDateTime(long seconds)
{
var d1970 = new DateTime(, , );
DateTime now = new DateTime(d1970.Ticks + seconds * );
///零时区
return TimeZoneInfo.ConvertTimeFromUtc(now, TimeZoneInfo.Local);
}

参考

https://stackoverflow.com/questions/47822177/swagger-net-core-api-ambiguous-http-action-debugging

Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0 异常的更多相关文章

  1. Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0

    异常内容 NotSupportedException: Ambiguous HTTP method for action . Actions require an explicit HttpMetho ...

  2. .Net Core Swagger:Actions require an explicit HttpMethod binding for Swagger 2.0

    添加完Swagger包引用后运行报错:Actions require an explicit HttpMethod binding for Swagger 2.0 第一时间想到了父类控制器 没有添加 ...

  3. .Netcore Swagger - 解决外部库导致的“Actions require an explicit HttpMethod binding for Swagger 2.0”

    现象: 项目中导入Ocelot后,swagger页面无法正常显示,查看异常发现 Ocelot.Raft.RaftController 中的 Action 配置不完全,swagger扫描时不能正确生成 ...

  4. Actions require unique method/path combination for Swagger

    原文:Actions require unique method/path combination for Swagger services.AddSwaggerGen (c => { c.Re ...

  5. 使用ControllerAdvice注意事项,Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]

    前言 ControllerAdvice非常好用,可以把系统内部的异常统一处理.用起来也很简单.比如,http://www.cnblogs.com/woshimrf/p/spring-web-400.h ...

  6. 解决Redisson出现Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'create' threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0的问题

    一.背景 最近项目中使用了redisson的哨兵模式来作为redis操作的客户端,然后一个意外出现了,启动报:Failed to instantiate [org.redisson.api.Redis ...

  7. 【netcore入门】在Windows IIS上部署.NET Core 2.1项目

    部署之前先检查下面2个先决条件是否满足 1.安装了 IIS 模块 win7 在 控制面板→程序和功能→打开或关闭Windows功能→勾选Internet 信息服务(Internet Informati ...

  8. Swagger使用的时候报错:Failed to load API definition

    NuGet添加Swashbuckle.AspNetCore,在Startup.cs添加和启用中间件Swagger public void ConfigureServices(IServiceColle ...

  9. 武装你的WEBAPI-OData常见问题

    本文属于OData系列 目录 武装你的WEBAPI-OData入门 武装你的WEBAPI-OData便捷查询 武装你的WEBAPI-OData分页查询 武装你的WEBAPI-OData资源更新Delt ...

随机推荐

  1. Vulkan SDK 之 Graphics Pipeline

    A graphics pipeline consists of shader stages, a pipeline layout, a render pass, and fixed-function ...

  2. windows平台上运行Flink_转载于CSDN

    Flink安装部署-window 本地部署原创冰上浮云 发布于2019-08-17 15:56:06 阅读数 633 收藏分类专栏: flink版权声明:本文为博主原创文章,遵循 CC 4.0 BY- ...

  3. Delphi 10.4 最新消息

    官方发布了关于10.4的消息,译文如下: 做为我们的Delphi,C ++ Builder和RAD Studio的订阅客户,除了获得更新,升级和技术支持等主要好处外,我们还邀请订阅客户参加Beta计划 ...

  4. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-facetime-video

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  5. OpenCV学习日志:计算机视觉资源汇总

    1.1 重要会议 (1)机器视觉重要会议 CVPR:Conferenceon Computer Vision and Pattern Recognition, IEEE, 五星 ICCV:Intern ...

  6. Adobe Photoshop CC2014 for MAC 详细破解步骤

    1,安装Adobe Photoshop CC2014 for MAC,可以断网安装,如果不断网的话,需要申请一个Adobe ID,是免费申请. 2,下载破解工具,https://sdifen.ctfi ...

  7. java String字符串判断

    判断空字符串:StringUtils.isBlank StringUtils.isBlank(null) = true StringUtils.isBlank("") = true ...

  8. 在开发过程中遇到的Oracle的坑及开发技巧

    本人与2018年毕业,工作一年多,仍是菜鸟,自毕业以来一直从事java软件开发工作,工作中大部分数据库都是使用的Oracle,碰到的问题总结一下(随时更新). 1.sql中使用group by 分组时 ...

  9. SQL left join、rignt join、inner join区别

    说真的一直对数据库没有研究以至于连这些基础都不会了,事实证明,业精于勤荒于嬉. 废话不多说,直接开始 有A.B两张表: 1.inner join inner join 和 join 是没有区别的(如有 ...

  10. Failed to connect to raw.githubusercontent.com port 443: Connection refused

    问题:macOS安装Homebrew时总是报错(Failed to connect to raw.githubusercontent.com port 443: Connection refused) ...