I am new to Web API and this is really puzzling to 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 am using an html form to post and it will hit 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 into the controller, the model object has firstname=null
and lastname
comes up correctly.
What I am doing wrong?