KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What would the equivalent asp.net mvc 4.0 code look like? using System.Net; using System.Net.Http; using System.Web.Mvc; using System.Threading.Tasks; using Newtonsoft.Json; namespace Web.Controllers { public class HomeController : Controller { private HttpClient httpClient = new HttpClient(); private static dynamic shots; public async Task<ActionResult> Index() { if (shots == null) { try { var responseMessage = await httpClient.GetAsync ("http://api.dribbble.com/shots/everyone?per_page=30"); responseMessage.EnsureSuccessStatusCode(); var value = await responseMessage.Content.ReadAsStringAsync(); shots = await JsonConvert.DeserializeObjectAsync<dynamic>(value); } catch (WebException) { } } return View(shots); } } }
Tags (comma-separated)
Save Edits
Cancel