I want to insert a partial view on an ASP.NET MVC page, returning it from an action method.
In my basic view, I would:
<%= Html.Action("MyPartialViewAction") %>
My controller will have an action method, for example:
[ChildActionOnly]
public ActionResult MyPartialViewAction()
{
return PartialView("MyPartialView");
}
I expected the returned partial view (MyPartialView) to access the ViewData that was set in the controller action of the main page, but that doesn't seem to be the case. If I insert a partial view using the following in my base view, it works:
<% Html.RenderPartial("MyPartialView") %>
I don't want to do this because I want my "MyPartialViewAction" to execute logic to determine which partial view WHICH returns.