Skip to content

Instantly share code, notes, and snippets.

@lukasz-pyrzyk
Created February 14, 2018 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukasz-pyrzyk/85cd3e589112e731c03923bb473e17eb to your computer and use it in GitHub Desktop.
Save lukasz-pyrzyk/85cd3e589112e731c03923bb473e17eb to your computer and use it in GitHub Desktop.
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace TestMvc.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
var jsonTask = GetData(new Uri("http://google.com"));
var data = jsonTask.Result;
return Content(data);
}
public async Task<string> GetData(Uri uri)
{
using (var client = new HttpClient())
{
var data = await client.GetStringAsync(uri);
return data;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment