0
空我在angularJS工廠代碼:MVC:AngularJS公佈的數據是在cotroller
myFactory.addNC = function (n) {
return $http.post('/api/addNC/', { c: n }).then(function (data) {
return data;
});
}
MVC ApiController:
[HttpPost]
public void addNC([FromUri]string c = null)
{
...
}
但 'C' 參數是空的,爲什麼?我在FireBug看到價值被張貼。
此外,如果我聲明像public void addNewCat([FromUri]string c)
這樣的參數,我會收到404錯誤 - 爲什麼?
難道您不希望'[FromBody]'用於POST嗎? – Clive 2014-11-22 11:54:28
然後我得到500錯誤:發生了錯誤。「,」ExceptionMessage「:」'FormatterParameterBinding'不支持可選參數'c'。「,」ExceptionType「:」System.InvalidOperationException – Tony 2014-11-22 12:01:14
哦,它只是一個字符串。嘗試完全刪除屬性 – Clive 2014-11-22 12:03:03