I've come to some strange behaviour using web api. I'm using attribute routing, and making post on server. Controller:
[Route("names")]
public ResultDTO SaveData(SomeDTO dto)
{
//somecode
...
}
and i'm calling it
$http.post('/api/mycontroller/names', $scope.model.dto).success(function
(data) { ...
It's working. However, if I rename my method
[Route("names")]
public ResultDTO GetData(SomeDTO dto)
{
//somecode
...
}
it's not working and I get HTTP 405 error The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access,
However it's working if I change calling from $http.post to $http.get
Obviously, I won't name my method starting with GetSomeMethod if I'm posting data, but I'm curious, shouldn't defined route
[Route("names")]
work with $http.post, no matter how I actually call method that will handle that post? More specific, why $http.post won't work if I named my method GetSomething, but it will if I change method name to, for example, GotSomething or SaveSomething?