I need to render a partial view to a string within a controller action. I have the following sample code, but the ControllerContext.ParentActionViewContext does not seem to exist in mvc 1.0
// Get the IView of the PartialView object.
var view = PartialView("MyPartialView").View;
// Initialize a StringWriter for rendering the output.
var writer = new StringWriter();
// Do the actual rendering.
view.Render(ControllerContext.ParentActionViewContext, writer);
Any tips greatly appreciated.
Here’s one way to achieve this. There’s also a BlockRenderer in MvcContrib.