I have a controller, action which returns PartialViewResult and view with it. For testing I output current DateTime (in action), and in view I check if it is null or not, so I know what I got.
When I try to "embed" that view in another one with Html.Action
I get current datetime, so my action is called.
But when I use Html.Partial
the view is rendered with null, my action method is not called. Besides, two breakpoints and debugger also confirms, in latter case the my action method is not called.
Action method:
public PartialViewResult Test()
{
return PartialView(DateTime.Now);
}
(partial) View:
@model DateTime?
<p>@(Model ?? DateTime.MinValue)</p>
and call from main view is either @Html.Action("Test")
or @Html.Partial("Test")
.