my code

Vishrut Jambudi

Call Web Api GET() method from MVC Controller of different project.
by Vishrut Jambudi

GET() Method

Snippet options

Download: Download snippet as call-web-api-get-method-from-mvc-controller-of-different-project.cpp.
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

 using (var client = new HttpClient())
 2             {
 3                 client.BaseAddress = new Uri("");
 4                 //client.DefaultRequestHeaders.Accept.Clear();
 5                 //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 6                 var response = client.GetAsync("Delete/" + id + "").Result;
 7                 if (response.IsSuccessStatusCode)
 8                 {
 9                     string responseString = response.Content.ReadAsStringAsync().Result;
10                     return RedirectToAction("Index");
11                 }
12             }

Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.