我設計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