【发布时间】:2016-01-04 03:05:09
【问题描述】:
我正在设计 2 个网站,并希望将 json 从第一个网站发送到第二个网站:
// Action from the first website
public async Task<ActionResult> Index()
{
using (var client = new HttpClient())
{
var package = new Dictionary<string, string>()
{
{ "Name", "Julie" }
{ "Address", "UK" }
};
string json = JsonConvert.SerializeObject(package);
var response = await client.PostAsync("thesecondsite.com/contacts/info", ???);
}
}
第二个网站Contacts控制器的动作Info:
[HttpPost]
public ActionResult Info()
{
// How can I catch the json here?
// string json = ...
}
你能告诉我如何获取json吗?
p/s:对于give me the code 的问题,我很抱歉,我一直在 Google 搜索中寻找,但在我的案例中没有找到样本。我想在服务器端执行此操作,而不是在客户端使用 ajax。
【问题讨论】:
标签: c# json asp.net-mvc dotnet-httpclient