/// <summary>
/// 测试处理
/// </summary>
public class TestController : ApiController
{
/// <summary>
/// 根据角色获取该角色所有拥有的功能
/// </summary>
/// <param name="roleid"></param>
/// <returns></returns>
[HttpPost]
[Common.AccessToken]
public Common.ResponseHeader GetByRole(int roleid)
{
return new Common.ResponseHeader { code=0,msg="",data=null};
} /// <summary>
/// 获取所有功能
/// </summary>
/// <returns></returns>
[HttpGet]
[Common.AccessToken]
public Common.ResponseHeader GetAll()
{
return new Common.ResponseHeader { code = 0, msg = "", data = null };
}
/// <summary>
/// 获取所在代理下的所有功能
/// </summary>
/// <param name="id">ces</param>
/// <returns></returns>
[HttpGet]
[Common.AccessToken]
public Common.ResponseHeader GetAll(int id)
{
return new Common.ResponseHeader { code = 0, msg = "", data = null };
}
}

这段代码会产生如下图的结果:

解决方案

对WebApiConfig中的路由进行修改

config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

重新运行  问题得到解决

关于swagger——WebApi一个controller中出现多个Get是出现错误的处理的更多相关文章

  1. WebApi一个控制器中定义多个Get方法。

    问题:怎样解决一个ApiController中定义多个Get方法或者Post方法? 答:要想实现一个ApiController中定义多个Get方法或者Post方法,则需要在WebApiConfig类中 ...

  2. C# WebApi的controller中如何存取session

    在MVC以后,Session方式可能已经不太常用,但偶尔还是会用到,比如页面验证码之类的.例如登录页面使用的验证码通过Controller提供一个View来实现,可以使用Session来存储这个值.但 ...

  3. Swagger使用--在一个Controller中使用相同(类似)参数的方法

    解决方法:在Startup.cs中加入CustomSchemaIds // Register the Swagger generator, defining 1 or more Swagger doc ...

  4. 【事件中心 Azure Event Hub】Event Hub Java SDK的消费端出现不消费某一个分区中数据的情况,出现IdleTimerExpired错误消息记录

    问题情形 使用Java SDK编写的Event Hub消费端应用,随机性遇见了某个分区没有消费消息的情况,在检查日志时候,有发现IdelTimeExpired的错误记录.在重启应用后,连接EventH ...

  5. 解决一个Ubuntu中编译NEON优化的OpenCV的错误

    在Ubuntu 16中编译开启NEON优化的Opencv时,遇到libpng编译是使用汇编代码的错误,完整错误见文章末尾.通过查询发现解决方案是安装跨平台编译器,安装代码如下: sudo apt-ge ...

  6. [.NET WebAPI系列03] WebAPI Controller 中标准CRUD方法

    [因] WebAPI的Controller中,一般都是下面四种方法: 对应于数据操作是我们通常所说的CRUD. C对应post,R对应Get,U对应Put,D对应Delete. 直接模仿VS 2012 ...

  7. SpringMVC中Controller跳转到另一个Controller方法

    1.直接Redirect后加 Controller/Action Response.Redirect("/User/Edit"); return Redirect("/U ...

  8. MVC中一个Form多个submit在controller中如何区分提交的是那个submit(如:登陆和注册)

    1. 用Html.BeginForm(ActionName,ControllerName,Post)来实现controller-action的路由, 2. Form里的每个input的name值统一, ...

  9. 在springMVC的controller中获取request,response对象的一个方法

    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttr ...

随机推荐

  1. [Swift]LeetCode848. 字母移位 | Shifting Letters

    We have a string S of lowercase letters, and an integer array shifts. Call the shift of a letter, th ...

  2. 利用U盘安装win2008r2系统的步骤

    我们在公司或者家里,经常要安装各种系统,最近公司需要重新安装win2008r2系统.折腾了一天的时间,终于把系统装好了.将安装的步骤记录下来,方便大家查看,自己也做个记录. 1 准备win2008r2 ...

  3. 关闭mac的SIP + 一定有用的删除mac自带ABC的方法

    如果你被这ABC输入法弄得很是不开心.那就看看吧!!!亲测一定有效. mac 关闭系统完整性保护 SIP(System Integrity Protection) 重启系统 按住 command+R ...

  4. Python __new__ 实现单例模式 python经典面试题

    话不多说,上代码 class Singleton(object): def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance' ...

  5. python入门学习记录(win7+python3.6)

    1. pip freeze 可以查看安装的模块信息 2. 查看某个模块是否已经安装了 conda(pip) search <moduleName>.图一显示为未安装,图二显示为已经安装

  6. [二]基础数据类型之Long详解

      Long   Long 基本数据类型long  的包装类 Long 类型的对象包含一个 long类型的字段     属性简介   值为  263-1 的常量,它表示 long 类型能够表示的最大值 ...

  7. 不要使用Resource Owner Password Credentials

    不要使用Resource Owner Password Credentials 文章链接在这里 前言 最近公司项目在做一些重构,因为公司多个业务系统各自实现了一套登录逻辑,比较混乱.所以,现在需要做一 ...

  8. JS_正则表达式_获取指定字符之后指定字符之前的字符串

    一个常见的场景,获取:标签背景图片链接: 如字符串:var bgImg = "url(\"https://img30.360buyimg.com/sku/jfs/t26203/26 ...

  9. WPF中Datagrid控件添加行号

    /// <summary> /// 导入Excel文件按钮 /// </summary> /// <param name="sender">&l ...

  10. MySQL 笔记整理(4) --深入浅出索引(上)

    笔记记录自林晓斌(丁奇)老师的<MySQL实战45讲> 4) --深入浅出索引(上) 一句话简单来说,索引的出现其实就是为了提高数据查询的效率,就像书的目录一样. 索引的常见模型 哈希表: ...