M
M
Maxim Akhmerov2018-04-25 21:15:00
ASP.NET
Maxim Akhmerov, 2018-04-25 21:15:00

How to solve the problem, does not see the controller's valuescontroller method?

I send a post request from the view to the ValuesController controller method

[AllowAnonymous]
[Route("api/values/PostClientIdInController")]
public string PostClientIdInController(Clients client)
{
........
}

And here is the Post request
$.ajax({
type: 'POST',
url: '/api/values/PostClientIdInController',
contentType: 'application/json',
data: JSON.stringify(client)
}).success(function (data) {
alert("Пользователь id отправлен");
}).fail(function (data) {
alert("В процесе отправки id польльзователя возникла ошибка");
});
})

The result is this error:
Could not find an HTTP resource matching the request URI "localhost:17224/api/values/PostClientIdInController".
An action matching the request could not be found on controller 'Values'.
The links are correct
, I also have a method, only with a different name, it works, but I don’t understand why this one doesn’t work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2018-04-25
@kttotto

Better do it through the [HttpPost] attribute, and not the Post prefix. Apparently, he considers the method as Get, so he does not see it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question