Why not use Html.RenderAction() ?
Then you can put the following into any controller (even creating a new controller for it):
[ChildActionOnly] public ActionResult MyActionThatGeneratesAPartial(string parameter1) { var model = repository.GetThingByParameter(parameter1); var partialViewModel = new PartialViewModel(model); return PartialView(partialViewModel); }
Then you can create a new partial view and have the PartialViewModel that it inherits from.
For Razor, the code block in the view will look like this:
@{ Html.RenderAction("Index", "Home"); }
For WebFormsViewEngine, it will look like this:
<% Html.RenderAction("Index", "Home"); %>
George Stocker Jun 09 '11 at 1:10 2011-06-09 01:10
source share