views:

69

answers:

0

I'm using MVC 2 and MVC Futures 2.0.50217.0.

I started with a view which repeatedly calls RenderAction(...) to include some external content implemented by another controller within my application. This is from the containing view:

<% foreach (var subModel in Model.SubModels) { %>
    <h3><%: subModel.Title %></h3>
    <% Html.RenderAction("MyAction", "MyController", subModel); %>
<% } %>

The subModel objects are instances of the model for the MyController.MyAction view which has some DataAnnotations validation attributes upon it. MyController.MyAction checks the model state is valid in order to choose a view to render. So far, so good.

However, if I use the MVC Futures' strongly typed helper to call RenderAction like so:

<% Html.RenderAction<MyController>(c => c.MyAction(subModel)); %>

...then the validation is not performed. Or at least, the model state does not indicate that the model is invalid.

What's going on? Am I doing something wrong or making an invalid assumption about the strongly typed helpers? Is there something I can do to validate the model automatically (i.e. without explicitly calling TryValidateModel).