用swagger访问https://localhost:44360/api/ads/1, 得到的结果是 TypeError: Failed to fetch。
一开始以为是后端代码问题,检查了好久,才发现是AdBlockPlus 把它当成广告过滤了。  
 

I have the following routing, which works on invokation /api/demo/info/34.

[Route("api/demo")]
public class Demo : Controller
{
[HttpGet("Info/{x}")]
public JsonResult GetInfos(string x) { ... }
}

Now, I'd like to pass a query string to select the ID, like so: /api/demo/info?x=34. How should I rephrase the attribute for that?

When I tried entering [HttpGet("Info?x={x}")], the error message said that the question mark isn't valid there. I want to resolve it through the attributive approach and routing from the default mapping isn't an option.

----------------------------------------------

All you should need to do is to declare your attribute as:

[HttpGet("Info")]

while keeping the signature of the method as GetInfos(string x). In a GET route, WebAPI picks up all the parameters from the signature, and those which aren't present in the route can be passed as query string arguments as long as the name in the query string matches the name of the parameter.

swagger访问api, TypeError: Failed to fetch的更多相关文章

  1. 【postman】postman测试API报错如下:TypeError: Failed to execute 'fetch' on 'Window': Invalid value 对中文支持不好

    使用postman测试APi的时候,因为系统需要在header部带上登录用户的信息,所以 如下: 然后测试报错如下:TypeError: Failed to execute 'fetch' on 'W ...

  2. Swagger请求报错:TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

    TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. 如下图 ...

  3. AspNetCore网关集成Swagger访问使用IdentityServer保护的webapi项目

    创建webapi项目 创建四个webapi项目,两个处理业务,一个网关,一个验证中心.四个项目对应的端口如下, ApiGateway:1999 IdentityServer:16690 Service ...

  4. NetCore 3.0 中使用Swagger生成Api说明文档及升级报错原因

    认识Swagger Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参 ...

  5. [转载]关于android SDK安装Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-1.xml出错

    原文地址为:http://blog.csdn.net/springsky_/article/details/7442388 因为入行移动测试,所以很多测试环境的搭建.从中遇到了和这个GG同样的问题.怕 ...

  6. android SDK Manager更新不了,出现错误提示:"Failed to fetch URL..."!

    可以用以下办法解决: 使用SDK Manager更新时出现问题 Failed to fetch URL https://dl-ssl.google.com/android/repository/rep ...

  7. Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Connectio (andriod sdk manager) http://dl-ssl.google.com/android上不去解决方案

    Fetching https://dl-ssl.google.com/android/repository/addons_list-2.xml  Fetched Add-ons List succes ...

  8. 从壹开始前后端分离 [.netCore 填坑 ] 三十四║Swagger:API多版本控制,带来的思考

    前言 大家周二好呀,.net core + Vue 这一系列基本就到这里差不多了,今天我又把整个系列的文章下边的全部评论看了一下(我是不是很负责哈哈),提到的问题基本都解决了,还有一些问题,已经在QQ ...

  9. SpringBoot整合Swagger测试api构建

    @Author:SimpleWu 什么是Swagger? Swagger是什么:THE WORLD'S MOST POPULAR API TOOLING 根据官网的介绍: Swagger Inspec ...

随机推荐

  1. Codeforces 85 D. Sum of Medians

    题目链接:http://codeforces.com/contest/85/problem/D 做法果然男默女泪啊..... 大概就是直接开了一个$vector$每次插入删除都用自带的$insert$ ...

  2. Git 中 pull 和 clone 的区别

    git pull git clone clone 是本地没有 repository 时,将远程 repository 整个下载过来. pull 是本地有 repository 时,将远程 reposi ...

  3. vue定义全局方法 调用其他组件的方法

    官网的写法  vue实例.$on就可以在根实例上定义全局方法 this.$root就是获取根实例  如果没有根实例 就表示当前实例 this.$root.$on 不需要.eventHub 不需要下面这 ...

  4. Spring 的@@Autowired 和 @Qualifier注释

    @Autowired spring2.1中允许用户通过@Autowired注解对Bean的属性变量.属性Setter方法以及构造方法进行标注,配合AutowiredAnnotationBeanProc ...

  5. 《剑指offer》第四十五题(把数组排成最小的数)

    // 面试题45:把数组排成最小的数 // 题目:输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼 // 接出的所有数字中最小的一个.例如输入数组{3, 32, 321},则打印出这3 ...

  6. Codeforces 493C - Vasya and Basketball

    C. Vasya and Basketball 题目链接:http://codeforces.com/problemset/problem/493/C time limit per test 2 se ...

  7. ionic日历插件

       1:引入插件的两个文件 timePicker.js 和timePicker.css文件    2:填加插件模块到项目模块中CorderYuan->app.js的moudule    3:在 ...

  8. Django - 将URL映射到视图

    URLconf 就像是 Django 所支撑网站的目录.它的本质是 URL 模式以及要为该 URL 模式调用的视图函数之间的映射表.你就是以这种方式告诉 Django,对于这个 URL 调用这段代码, ...

  9. English Voice of <<Bye Bye Bye>>

    Bye Bye Bye - Lovestoned When i see you, looking back at me 当我看到你回首看我时 Watching this eye still 彼此凝视 ...

  10. java学习进度

    上周日玩的比较high,忘记写进度报告,今天补上.通过这些天的学习,我对java有了初步的认识,java和c有很多的不同和相同之处,然后就是java的代码在记事本里写,等慢慢深入之后又可以用eclip ...