using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Web; using System.Web.Http; using System.Web.Mvc; using WebAPIDemo.Models; namespace WebAPIDemo.Controllers { public class PersonController : Controller { // GET: Person public ActionResult Index() { using (var client=new HttpClient()) { var personListServiceUrl = GetPersonListServiceUrl(); var personList = CallPersonListServiceAsync(client, personListServiceUrl); return View(personList); } } public string GetPersonListServiceUrl() { return Url.RouteUrl("DefaultApi", new { httproute = true, controller = "PersonService" }, Request.Url.Scheme); } private IEnumerable CallPersonListServiceAsync(HttpClient client, string serviceurl ) { client.GetAsync(serviceurl); //todo } } } If you guys want, i can send whole lab and my code. Thanks.
private IEnumerable<person> CallPersonListServiceAsync(HttpClient client, string serviceurl ) { return client.GetAsync(serviceurl).Result.Content.ReadAsAsync<ienumerable><person>>().Result; }</person></ienumerable></person>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)