1 回答

TA貢獻(xiàn)1878條經(jīng)驗(yàn) 獲得超4個贊
你可以通過閱讀來做到這一點(diǎn)Request.InputStream
[HttpPost]
public ActionResult SaveResponse()
{
string json;
using (var reader = new StreamReader(HttpContext.Request.InputStream))
{
json = reader.ReadToEnd();
}
return View("CallbackView");
}
或者您可以接受string參數(shù),模型綁定器將為您完成所有工作,但您需要通過json參數(shù)將數(shù)據(jù)作為字符串傳遞。一些可用的選項(xiàng)
設(shè)置Content-Type: application/json和有效載荷{"json": "{id:44}"}
設(shè)置Content-Type: x-www-form-urlencoded和有效載荷json={id:44}
行動
[HttpPost]
public ActionResult SaveResponse(string json)
{
return View("CallbackView");
}
- 1 回答
- 0 關(guān)注
- 124 瀏覽
添加回答
舉報