This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfstring xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<string>value1</string>
<string>value2</string>
</ArrayOfstring>
This XML file does not appear to have any style information associated with it. The document tree is shown below.呵呵,可以看出,http://localhost:65134/api/value 路由到了 public IEnumerable<string> Get() 方法,而 http://localhost:65134/api/value/5 路由到了 public string Get(int id)。
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">value</string>
注:使用浏览器测试 Web Api 并不是一个好主意,它不太好测试其它诸如 POST/PUT/DELETE 方法。建议使用大名顶顶的 Fiddler 神器,可以构造参数和选择方法。呵呵,个人认为最好的测试办法是
编写一个网页,在网页中使用 jQuery Ajax 编写一段小程序在 Chrome浏览器/360极速浏览器中进行测试,因为 Chrome 的调试工具箱非常强大。
注:约定俗成,控制器中方法名称以“Get”开头的方法默认为“HttpGet”方法,以此类推,“Post”开头的方法默认为“HttpPost”方法...,它们不必注明[HttpGet]/[HttpPost]...。否则,必须方法定义的上一行用[HttpGet]/[HttpPost]...注明方法。呵呵,ASP.NET Web Api 和 Mvc 中有很多约定俗成规定。[groupid=322]ACC应用开发心得交流[/groupid]
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |