larryq
larryq

Reputation: 16299

MVC 3: render action in different controller from view

I must be missing something obvious. I have a view A in controller B that needs to call and render an action method Y in controller Z.

Should I be doing something like this in view A ? I'm getting errors in VS about how it can't resolve action '/Z/Y'

@Html.RenderAction("/Z/Y", new ModelUsedInActionMethodY())

Upvotes: 0

Views: 1253

Answers (1)

HTX9
HTX9

Reputation: 1717

You need to use:

@Html.RenderAction("Y", "Z")

This will route to Action Method Y in ZController. See the MSDN documentation for a complete list of method signatures for Html.RenderAction().

Upvotes: 3

Related Questions