I have a form that I cannot get to bind values to my model. The model is empty on the post action.
I've stripped everything down to the simplest of examples and still can't get it to bind.
The model
public class simplemodel
{
public string SomeVal;
}
The view
@model MyApp.Models.simplemodel
@using(Html.BeginForm("Index", "Test", FormMethod.Post))
{
@Html.TextBoxFor(m => m.SomeVal);
<input type="submit" value="submit" id="btnSubmit" />
}
The controller action
[HttpPost]
public ActionResult Index(simplemodel model)
{
string ReceivedVal = model.SomeVal;
//do whatever...
}
This is as straight forward as it gets, but my model doesn't bind.
ReceivedVal is always empty. I have plenty of other places where I'm binding to models with no issue. I'm baffled. What could I possibly be missing?
I do receive "SomeVal" if I change the controller action to receive a FormCollection. So I know it's getting posted properly, it just won't bind to the model.