asp.net mvc 1.0 - how to render a partial view as a string
- by Chev
Hi There
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.