Я сделал несколько предыдущих вопросов с просьбой помочь с проблемами, так как я обновил MVC4 webapi beta до RC. Я получил больше всего в порядке, но здесь я еще не могу понять причину.
Для этого простого контроллера у меня есть тот, который принимает POST и тот, который принимает GET. Когда я пытаюсь запустить их, отправив запрос из HTML-формы, будет найден только контроллер GET, в то время как POST возвращает мне следующую ошибку.
{
"Message": "No HTTP resource was found that matches the request URI 'http://localhost/webapi/api/play/test'.",
"MessageDetail": "No action was found on the controller 'Play' that matches the name 'test'."
}
Почему контроллер POST не найден?
Контроллеры
public class PlayController : ApiController
{
[HttpPost] // not found
public string Test(string output)
{
return output;
}
[HttpGet] // works
public string Test2(string output)
{
return output;
}
}
HTML-форма
<form action="http://localhost/webapi/api/play/test" method="post">
<input type="text" name="output" />
<input type="submit" name="submit" />
</form>
<form action="http://localhost/webapi/api/play/test2" method="get">
<input type="text" name="output" />
<input type="submit" name="submit" />
</form>