質問

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());}
役に立ちましたか?

解決

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())
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top