首先,要知道webApi的基本返回方式是HttpResponseMessage,post会在响应中返回添加的对象,以及添加对象的访问地址

如:在fiddler里测试的时候

然后,我们可以根据这一点在后台方法中进行操作,在添加方法中获得刚加入的数据。

 //添加操作
ProductService.AddProduct(product);
//获得添加的响应
var response = Request.CreateResponse<Product>(HttpStatusCode.Created, product);
//获得访问地址
string uri = Url.Link("DefaultApi", new { id = product.ProductID });
//获得刚添加数据的id
int id = product.ProductID;

注:仅为个人理解与笔记,有错误的地方请指正O(∩_∩)O!

最新文章

  1. PHP获得两个绝对路径的相对路径
  2. ORACLE 语句关联统计
  3. 高性能CSS(二)
  4. mysql insert语句错误问题解决
  5. MVC中不能使用原生态的#include ,可替代的解决方案
  6. silverlight visifire控件图表制作——silverlight 后台方法打印
  7. OpenSSl 加密解密 示例(终于有编程实践了)
  8. VS2012添加对DirectX SDK中需要文件的引用
  9. [Hadoop] - 自定义Mapreduce InputFormat&amp;OutputFormat
  10. vue 实现 换一换 功能
  11. python+eclipse+pydev开发环境搭建
  12. 计算机网络之套接字SOCKET
  13. Python生成器的原理及使用
  14. IDEA cannot resolve symbol “xxxx”
  15. Linux 自动化部署Rsyslog服务
  16. 使用nvm安装node,全局npm,cnpm
  17. SparkSQL demo
  18. Oracle数据库查看SID和service_name
  19. Java设计模式应用——桥接模式
  20. 【mysql】测试方案整理

热门文章

  1. Notes of the scrum meeting(12.10)
  2. 20172314 Android程序设计 实验四
  3. 团队第一次作业 ——404 Note Found 团队
  4. Windows 7中安装Solr7
  5. yum 安装 redis php-redis
  6. python redis插件安装
  7. 数据存储到MySQL并返回新插入的id值
  8. 【转】关于增量链接(incremental linking)
  9. Redis 学习之主从复制
  10. java.awt.AWTError: Can&#39;t connect to X11 window server using &#39;:20&#39; as the value of the DISPLAY variable