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

问题:有些接口没有设置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. 151-PHP nl2br函数(二)

    <?php $str="h\nt\nm\nl"; //定义一个多处换行的字串 echo "未处理前的输出形式:<br />{$str}"; $ ...

  2. 073-PHP数组元素相加

    <?php $arr1=array(1,2,3,4,'5','05',TRUE); //等价于 1+2+3+4+5+5+1=21 $arr2=array(1,2,'ABC',3,'hello', ...

  3. 第二阶段scrum-6

    1.整个团队的任务量: 2.任务看板: 会议照片: 产品状态: 消息收发功能正在制作

  4. 关于C#设计SQllite

    使用3.5框架+System.Data.SQLite,System.Data.SQLite.Ling+SQLite.Designer三个dll

  5. Bulma CSS - 开始

    Bulma CSS框架教程 Bulma CSS – 简介 Bulma CSS – 开始 Bulma CSS – CSS类 Bulma CSS – 模块化 Bulma CSS – 响应式 有数种方法可以 ...

  6. 在Mac上使用docker+sql server+Navicat

    1. 版本:  2. 安装Kubernetes(并不知道安装这个有什么用) git clone https://github.com/maguowei/k8s-docker-desktop-for-m ...

  7. # vim ~/.vimrc vim配色

    Ubuntu # vim ~/.vimrc        # /hom/zzx 下 set nomodeline                "(这个一定要写,目前有这个安全漏洞) set ...

  8. Java IO 乱码

    InputStreamReader isr = new InputStreamReader(new FileInputStream("./test/垃圾短信训练集80W条.txt" ...

  9. 在Linux下 MySQL错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决办法【很管用】

    一般这个错误是由密码错误引起,解决的办法自然就是重置密码. 假设我们使用的是root账户. 1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下: #vim /etc/my.cnf(注:wi ...

  10. part8 vue内置标签keep-alive对网页性能优化

    我们网页请求时候 我们点击路由切换 可以看network中数据请求 因为每次路由切换都会执行mounted钩子函数 我们这个函数中数据请求 //每次切换路由,页面都会重新渲染 在根组件中使用 路由切换 ...