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

问题:有些接口没有设置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. StackExchange.Redis.DLL 操作redis简化版

    直接引入StackExchange.Redis.dll来操作redis using Newtonsoft.Json; using StackExchange.Redis; using System; ...

  2. js利用递归生成随机数填充到数组

    用递归算法实现,数组长度为5且元素的随机数在2-32间不重复的值 var  array = new Array(5); function addNumToArray(array,num){     i ...

  3. 控制数据的小数位数 java / js

    //java一般控制格式都是通过 DecimalFormat 来控制的.下边是个例子. import java.text.DecimalFormat; public class ControlBit ...

  4. Storm 流式计算框架

    1. 简介 是一个分布式, 高容错的 实时计算框架 Storm进程常驻内存, 永久运行 Storm数据不经过磁盘, 在内存中流转, 通过网络直接发送给下游 流式处理(streaming) 与 批处理( ...

  5. 最小编辑距离python

    1 什么是编辑距离在计算文本的相似性时,经常会用到编辑距离(Levenshtein距离),其指两个字符串之间,由一个字符串转成另一个所需的最少编辑操作次数.在字符串形式上来说,编辑距离越小,那么两个文 ...

  6. spring学习第7天(PCD以及切点表达式)

    1.PCD(PointCutDesigner) spring的aop只针对方法进行aop代理,而apectj联盟的aop比之更加强大,还可以针对字段等进行切面编程 1.1:execution,用的最多 ...

  7. 11 ~ express ~ 解决 cookie 中文报错的问题

    使用cookies包需要注意:1,cookie中是不能有中文的,一旦有中文,就会报错2,cookie是通过 中间件的形式直接挂载到 req对象上的,那么cookies有的方法,req.cookies就 ...

  8. 剑指offer_2.1_Day_5

    输入一个链表,按链表从尾到头的顺序返回一个ArrayList. import java.util.ArrayList; public class Solution { public ArrayList ...

  9. 对python中元类的理解

    1. 类也是对象 在大多数编程语言中,类就是一组用来描述如何生成一个对象的代码段.在Python中这一点仍然成立: >>> class ObjectCreator(object): ...

  10. hash表系列(转)

    http://www.cnblogs.com/mumuxinfei/p/4441826.html 前言: 我以前在百度的mentor, 在面试时特喜欢考察哈希表. 那时的我满是疑惑和不解, 觉得这东西 ...