How to call WEB API in ASP.NET MVC

public class ProductController : Controller
{
    HttpClient Client = new HttpClient();
    Uri BaseAddress = new Uri("http://localhost:131/");
    public ActionResult Index()
    {
        Client.BaseAddress = BaseAddress;
        HttpResponseMessage response =
       Client.GetAsync("productservice/GetProducts").Result;

        if (response.IsSuccessStatusCode)
        {
            var data = response.Content.ReadAsAsync<IEnumerable<Product>>().Result;
            return View(data);
        }
        return View();
    }
}

results matching ""

    No results matching ""