在很多时候,我们是希望手机app是要和服务端关联,并获取服务端的数据的,本篇博文我们看一下在xmarin下,怎么和用web api的方式与服务端连接并获取数据。
首先看web api的开发,本实例是用Visual Studio 2013 with update 4开发


然后创建一个实体类City
public class City
{
public int Code
{ get; set; }
public string Name
{ get; set; }
}
再创建一个WebApiController
[RoutePrefix("api")]
public class TestController : ApiController
{
[HttpGet]
[Route("citys")]//通过路由设计为citys
public IHttpActionResult GetCitys()
{
var citys =
|