我设计2个网站,并想从第一个网站发送一个JSON到第二:在第二个网站Contacts
控制器发送,并通过HttpClient的接收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", ???);
}
}
行动Info
:
[HttpPost]
public ActionResult Info()
{
// How can I catch the json here?
// string json = ...
}
你能告诉我如何获得json吗?
p/s:对不起,give me the code
问题,我一直在寻找谷歌搜索,但没有发现样品在我的情况。我想在服务器端做这个,而不是在客户端使用ajax。
这个问题解决了吗? – Nkosi