When I'm in a View and I call @Html.RenderPartial("MyPartialView", MyObject)
Can I set it up so that this partial view has a controller which is called when RenderPartial gets called?
Asked
Active
Viewed 7,177 times
7

tereško
- 58,060
- 25
- 98
- 150

dev.e.loper
- 35,446
- 76
- 161
- 247
3 Answers
9
Probably it will be better to use the RenderAction instead of the RenderPartial

Mikhail
- 9,186
- 4
- 33
- 49
-
Yes. It looks like I need to use RenderAction instead. Also found this helpful http://stackoverflow.com/questions/3968664/asp-net-mvc-2-0-difference-between-renderpartial-and-renderaction – dev.e.loper Jul 05 '11 at 21:00
1
You should gather all data necessary for the partial in the current controller action (which may use methods shared across other controllers and actions).
If you really want a partial to be rendered using its own controller/action then consider loading it via AJAX with a separate request.

Wizard of Ogz
- 12,543
- 2
- 41
- 43
0
In MVC, although controllers know about views, the reverse is not true.
Views are just means to render some data (a model or a viewModel) but they are not related to a controller or an action.

Hector Correa
- 26,290
- 8
- 57
- 73