Created
February 14, 2018 19:19
-
-
Save lukasz-pyrzyk/85cd3e589112e731c03923bb473e17eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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