Question

So within the layout of my site I've added a RenderAction that looks like this:

@{Html.RenderAction("../Controller/Action", new Site.Models.Controller());}

The control works fine if I point my browser at site.com/Controller/Action but if I try using it within the layout the controller actions aren't executed.

I've also tried:

@{Html.RenderAction("Controller", "Action", new Site.Models.Controller());}
Était-ce utile?

La solution

You have inverted the parameters. First comes the action name and then the controller name:

@{Html.RenderAction("Action", "Controller", new Site.Models.Controller());}

or the equivalent:

@Html.Action("Action", "Controller", new Site.Models.Controller())
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top