【发布时间】:2013-11-26 20:33:52
【问题描述】:
我有两个 MVC 网站。站点 1 有一个控制器,它使用以下代码调用站点 2
// If I remove this in the controller of site1, then execution continues....
var asdf = SharedTypes.Utilities.GetjsonStream("http://localhost:11541/UIDP/Details/a1?format=json");
string g = asdf.Result;
public class Utilities
{
public static async Task<string> GetjsonStream(string url)
{
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(url);
string content = await response.Content.ReadAsStringAsync();
Debug.WriteLine("Content: " + content);
return content;
}
}
我可以直接浏览 URL 并查看 JSON.. 但是在 MVC 中从我的对等网站下载 JSON 的正确方法是什么?
【问题讨论】:
标签: c# asp.net-mvc json asp.net-mvc-4 asynchronous