一,控制器代码:

[RoutePrefix("ajilisiwei")]  //加URL前缀 (非必需)
    public class ShoppingController : ApiController
    {

[HttpPost]
        [Route("Test/{product}")] 
        public IEnumerable<Product> AddProduct([FromUri]string product,[FromBody] object param)
        {
            return null;
        }

[HttpPost]
        [Route("Test/{product}/{id}")]
        public Product UpdateProduct([FromUri]string product,[FromUri]string id,[FromBody] object param)
        {
            return null;
        }

}

二.Fiddler测试

(1). http://localhost:1867/ajilisiwei/test/T-shirt  路由到  AddProduct

注意:请求实体的里的参数 param的类型在Action里要为object , 否则接收不到

(2).http://localhost:1867/ajilisiwei/test/T-shirt/2  路由到  UpdateProduct

asp.net Web API简单的特性路由配置的更多相关文章

  1. ASP.NET Web API框架揭秘:路由系统的几个核心类型

    ASP.NET Web API框架揭秘:路由系统的几个核心类型 虽然ASP.NET Web API框架采用与ASP.NET MVC框架类似的管道式设计,但是ASP.NET Web API管道的核心部分 ...

  2. ASP.NET Web API实践系列03,路由模版, 路由惯例, 路由设置

    ASP.NET Web API的路由和ASP.NET MVC相似,也是把路由放在RouteTable中的.可以在App_Start文件夹中的WebApiConfig.cs中设置路由模版.默认的路由模版 ...

  3. ASP.NET Web API 通过Authentication特性来实现身份认证

    using System; using System.Collections.Generic; using System.Net.Http.Headers; using System.Security ...

  4. ASP.NET Web API实践系列04,通过Route等特性设置路由

    ASP.NET Web API路由,简单来说,就是把客户端请求映射到对应的Action上的过程.在"ASP.NET Web API实践系列03,路由模版, 路由惯例, 路由设置"一 ...

  5. ASP.NET Web API 2 中的特性路由

    ASP.NET MVC 5.1 开始已经支持基于特性的路由(http://attributerouting.net),ASP.NET WEB API 2 同时也支持了这一特性. 启用特性路 由只需要在 ...

  6. ASP.NET Web API 路由对象介绍

    ASP.NET Web API 路由对象介绍 前言 在ASP.NET.ASP.NET MVC和ASP.NET Web API这些框架中都会发现有路由的身影,它们的原理都差不多,只不过在不同的环境下作了 ...

  7. ASP.NET Web API 特性

    ASP.NET MVC 4 包含了 ASP.NET Web API, 这是一个创建可以连接包括浏览器.移动设备等多种客户端的 Http 服务的新框架, ASP.NET Web API 也是构建 RES ...

  8. ASP.NET Web API Selfhost宿主环境中管道、路由

    ASP.NET Web API Selfhost宿主环境中管道.路由 前言 前面的几个篇幅对Web API中的路由和管道进行了简单的介绍并没有详细的去说明一些什么,然而ASP.NET Web API这 ...

  9. 剖析Asp.Net Web API路由系统---WebHost部署方式

    上一篇我们剖析了Asp.Net路由系统,今天我们再来简单剖析一下Asp.Net Web API以WebHost方式部署时,Asp.Net Web API的路由系统内部是怎样实现的.还是以一个简单实例开 ...

随机推荐

  1. 二十一、curator recipes之TreeCache

    简介 curator的TreeCache允许对某个路径的数据和路径变更以及其下所有子孙节点的数据和路径变更进行监听. 官方文档:http://curator.apache.org/curator-re ...

  2. 量子猴排(Quantum Bogo sort)

    排序原理 原理很简单,如果数组不是有序的,就洗一次牌,直至数组有序为止 时间复杂度 最佳情况O(n),平均情况O(n×n!) 代码如下: import java.util.Random; public ...

  3. (mysql)找不到请求的 .Net Framework Data Provider。可能没有安装

    webconfig配置以下节点(注意版本号) <system.data> <DbProviderFactories> <add name="MySQL Data ...

  4. sql SUM求和

  5. struts2 上传下载文件,异常处理,数据类型转换

    一,web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version=" ...

  6. python中垃圾回收机制

    Python垃圾回收机制详解   一.垃圾回收机制 Python中的垃圾回收是以引用计数为主,分代收集为辅.引用计数的缺陷是循环引用的问题.在Python中,如果一个对象的引用数为0,Python虚拟 ...

  7. 使用 Vuejs 开发 chrome 插件的注意事项

    使用 Vuejs 开发 chrome 插件 chrome 插件的开发其实并不难,web开发者可以使用 html, css, javascript 轻松的开发实用的 chrome 插件. 一个好的 ch ...

  8. php Closure::bind的参数说明

    publicstatic Closure Closure::bind ( Closure $closure , object$newthis [, mixed$newscope = 'static' ...

  9. mysql 导入时报错:Got a packet bigger than‘max_allowed_packet’bytes

    原因是max_allowed_packet 值设置过小. 网上粘贴一段定义: max_allowed_packet:指代mysql服务器端和客户端在一次传送数据包的过程当中数据包的大小这个是定义mys ...

  10. angular2.0---服务Service,使用服务进行数据处理

    1.创建服务 打开命令窗口,cd到项目目录下,输入  ng g service myData1  回车 创建服务,如下图所示: 这样就成功创建了服务,此时,可以在项目的app文件夹下生成了两个serv ...