Part 2 - How to retrieve data from the database in the ASP.NET Web API using Http Client

In this post, I am going to explain How to retrieve data from the database in the ASP.NET Web API using Http Client.


In the previous part I have explained Part1 - How to retrieve data from the database in the ASP.NET Web API using Jquery

Part 2 - Fetch data from WebApi using Http Client
Name Email City Country
kkk kkk
anji er
anji er
sper satar [email protected] as usa
sper satar [email protected] as usa
pavan nalla [email protected] nrt india
sdfsd dsfd [email protected] sdfs sdfds
N P
ba ha [email protected] ha iraq
pavan nalla [email protected] gnt india
23423423 2323432 [email protected] 23423423 23423423
s s [email protected] hyd india
ritesh pandey [email protected] delhi India
hkj hhkh [email protected] pune India
a a
sc s
df adf [email protected] dfs dsf
SANTHOSH P [email protected] hyderabad india
santhosh p [email protected] hyderabad india
santhosh p [email protected] hyderabad india
santhosh kumar [email protected] hyderabad india
santhosh kumar [email protected] hyderabad india
rampaul rb [email protected] chennai India
zsdcdsa saadasdads
heena singh [email protected] sirsa india
sdgjhJH GJHGSAHDFJG [email protected] fkjghkjh United Arab Emirates
sdgjhJH GJHGSAHDFJG [email protected] fkjghkjh United Arab Emirates
test ttt [email protected] te te
test test [email protected] test test
c d [email protected] f r
vhgfh fghfg [email protected]
asfaf sas [email protected]
sdas sas
test test [email protected] hhhh us
hjhkjhk ,njk [email protected] jhjhj mjknj
vishal sohaliya [email protected] amreli india
Sourav Mondal
sasdf sdf
Sourav Mondal [email protected] Kolkata India
AA AA [email protected]
Hshhsh Bnznnz [email protected] Jjjns Nndbz
kuntal patel [email protected] ahmedabad India
mallesh ATLA
Sourav1111111 Mondal [email protected] Kolkata India
Sourav11 Mondal [email protected] Kolkata India
Ajit Gangurde [email protected] Pune india
Rohan Thakur [email protected] New Delhi India
cvvc cvcvc
sd sd
g v [email protected] fgh hh
g v [email protected] fgh hh
Anand Khobragade [email protected] Nagpur India
asdaasd ads
Amo kmk [email protected] llk ll
hu Arun
hu Arun
bipin singh [email protected] gurgaon india
ww ww [email protected] mim india
aasdasdas gdsfg
uyt87t97g jhygyigiug
uyt87t97g jhygyigiug
gfhfhhgf gfhgfhgfhgf
mmm mmm [email protected] mmm mmmm
sdsdg dfgdfg
ghth thbgh
krishna hari [email protected] in un
Sourav Mondal [email protected] Kolkata India
Sourav Mondal [email protected] Kolkata India
Anne Dodsworth [email protected] London UK
Laura Callahan [email protected] Seattle USA
Robert King [email protected] London UK
Michael Suyama [email protected] London UK
Steven Buchanan [email protected] London UK
Margaret Peacock [email protected] Redmond USA
Janet Leverling [email protected] Kirkland USA
Andrew Fuller [email protected] Tacoma USA
Nancy Davolio [email protected] Seattle USA
Part 2 - How to retrieve data from the database in the ASP.NET Web API using Http Client
Share This Tutorial
using Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.Mvc;

namespace WebApiClient.Web.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Part1()
        {
            return View();
        }

        public ActionResult Part2()
        {
            List<Employee> list = new List<Employee>();
            HttpClient client = new HttpClient();
            var result = client.GetAsync("http://localhost:1963/api/Example").Result;
            if (result.IsSuccessStatusCode)
            {
                list = result.Content.ReadAsAsync<List<Employee>>().Result;
            }
            return View(list);
        }
    }
}

Posted By : Sourav Mondal