I'm new to the Web API, and it really puzzles me.
Here is the model:
public class Model { public string firstname { get; set; } public string lastname { get; set; } }
here is the controller:
public class TestController : ApiController { [HttpPost] public void Test(Model request) { } }
I use the html form for publishing and it will get to the controller:
<html> <head> <title></title> </head> <body> <form action="/Test" method="post"> <input type="text" name="firstname" value="test1" /> <input type="text" name="lastname" value="test2" /> <input type="submit" value="Submit" /> </form> </body> </html>
However, when I debug the controller, the model object has firstname=null and lastname correctly.
What am I doing wrong?
source share