1
我正在做一个Web API调用,我得到这个错误:HTTPGET属性必须为一个方法,但不是另一个
405 Method Not Allowed
The requested resource does not support http method 'GET'.
这里是呼叫:
var config = {
url: rootWebApiUrl + '/api/containerMove/allowMultipleBoxesPerMove',
method: 'GET'
};
$http(config)
.then(function (response) {
// code here
}, function (response) {
// code here
});
如果我在HTTPGET属性添加到Web API方法,它的工作原理:
[HttpGet]
[Route("api/containerMove/allowMultipleBoxesPerMove")]
public bool AllowMultipleBoxesPerMove()
我不明白的是,HttpGet
不是NE用于在同一个Web API控制器上进行的其他调用。这里有一个,如果没有HttpGet
属性适用于:
var config = {
url: rootWebApiUrl + '/api/containerMove/getBatchRefreshInterval',
method: 'GET'
};
$http(config)
而且网页API方法:
[Route("api/containerMove/getBatchRefreshInterval")]
public int GetBatchRefreshInterval()
那么,为什么我需要HttpGet
一个网页API方法而不是其他?这些调用和API方法几乎完全相同。