D'Arcy Rittich
D'Arcy Rittich

Reputation: 171559

How can I render a different controller's action from within a view?

I know that within a view I can render an action from the same controller using Html.RenderPartial. However, I need to render the output from an action under a different controller. What is the best way to do this? I would prefer to do this directly within the view, rather than doing it in the controller and saving the output to a ViewData variable.

Upvotes: 2

Views: 2230

Answers (2)

Garry Shutler
Garry Shutler

Reputation: 32698

The best thing to do is use Html.RenderAction which needs a references to the 'Futures' assembly Microsoft.Web.Mvc which there's a question about how to get it.

You will also need to add the namespace in your web.config in order to user it in your view:

<add namespace="Microsoft.Web.Mvc"/>

Upvotes: 1

E Rolnicki
E Rolnicki

Reputation: 1717

I would look at Steve Sanderson's implementation of "Partial Requests" found here

Upvotes: 0

Related Questions