我想調用的方法ProcessCriteria在AngularJS以下,但由於某種原因,我不斷收到錯誤消息:
VM18010:1 POST (未找到)
下面是我的調用代碼:
var param = { 'Item': item.Key, 'SolrLabel': SolrLabel };
$http({
method: 'POST',
url: '/api/TalentPool/ProcessCriteria',
data: param
//headers: {
// 'Content-Type': 'application/x-www-form-urlencoded'
//}
}).then(function (response) {
// success
console.log('Facet Data Posted');
return response;
},
function (response) { // optional
// failed
console.log('facet post error occured!');
});
我的服務器端方法:
[System.Web.Http.HttpPost]
public IHttpActionResult ProcessCriteria(string Item, string SolrLabel)
{
var itm = Item;
var solr = SolrLabel;
return Ok();
}
任何建議嗎?
404表示您試圖發佈的頁面不存在。您可能在網址中存在錯誤。 – Mistalis
你肯定API端點啓動和運行 - 嘗試將簡單的GET方法,看看您是否可以在瀏覽器中點擊它。 –
網址是正確的,因爲我可以通過瀏覽器導航到它。因爲你有你的行動2組的參數和路由器不明白 – ShK