如何通過郵寄方式發送純文本控制器發送純文本到控制器mvc4
public ActionResult mappingNodes(string model) {
var test = model;
return Json(new { foo = "bar"});
}
:
$http.post("/msm/test/mappingNodes", postModel, { headers: { 'Content-Type': 'text/plain'}})
如果我選擇了postModel
一個字符串,如「ABC」或'{model : "abc"}'
我在控制器端獲得null。
如果我更改參數Content-Type
到application/jason
我得到「ABC」在控制器端,如果如果postModel
設置的postModel
設置爲'{model : "abc"}'
爲「ABC」我得到的錯誤狀態代碼500在我的errorCallback函數。
如果我嘗試你的建議,並將'postModel'設置爲'{model:「{\」abc \「:\」test \「}」}'我的errorCallback中還有狀態碼500。 – StellaMaris