When I create a form to send data about new message:
<% using (Html.BeginForm()) { %>
<%= Html.TextAreaFor(m => m.Message.Text) %>
<input type="submit" />
<% } %>
I can't receive the message class in the controller:
[HttpPost]
public ActionResult NewMessage(Message message) // will not work, message is null
Instead I have to use the model class that's passed to the view and then get the child class from it
[HttpPost]
public ActionResult NewMessage(NewMessageModel model) {
Message message = model.Message;
And only after that I can do validation stuff.
Is there a way to pass a certain object to the controller?