I'm trying to render a partial view on my master page using Html.RenderAction() in VS 2010 using MVC2. Here is my RenderAction() call:
<% Html.RenderAction(
"Menu",
"Navigation",
new
{
currentAction = ViewContext.RouteData.Values["action"],
currentController = ViewContext.RouteData.Values["controller"]
}
); %>
However, when it its the Navigation controller's constructor, it always hits the constructor that is defined with no arguments.
public class NavigationController : Controller
{
public NavigationViewModel navigationViewModel { get; set; }
public NavigationController()
{
-snip-
}
public NavigationController( string currentAction, string currentController )
{
-snip-
}
[ChildActionOnly]
public ViewResult Menu()
{
return View(this.navigationViewModel);
}
}
Of all the examples I have seen, this is how you would pass arguments using a RenderAction() call. I don't get any error messages other than it complains if I remove the constructor with no arguments defined.
How can I get it to call the constructor which has the two arguments defined? I'd like to be able to compare to the currentAction and currentController when building the menu to correctly highlight the section the user is currently on.