等效的 asp.net mvc 4.0 代码是什么样的?
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);
}
}
}