I did some previous questions asking for help with the problems, since I upgraded MVC4 webapi beta to RC. I got the most in order, but here I still can not understand the reason.
For this simple controller, I have one that accepts POST and one that accepts GET. When I try to run them by sending a request from an HTML form, only the GET controller will be found, while POST returns me the following error.
{ "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'." }
Why is the POST controller not found?
Controllers
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
<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>
html-form asp.net-web-api asp.net-mvc-4
starcorn Sep 02 2018-12-12T00: 00Z
source share