In MVC 2 with the regular view engine i could return a ascx partial view as string through return Json()
But with the new Razor .cshtml views I can not
This is the MVC 3 Beta version of the code:
private string ControlToString(string controlPath, object model)
{
//CshtmlView control = new CshtmlView(controlPath);
RazorView control = new RazorView(this.ControllerContext, controlPath, null, false, null);
this.ViewData.Model = model;
HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter());
control.Render(new ViewContext(this.ControllerContext, control, this.ViewData, this.TempData, writer), writer);
string value = ((StringWriter)writer.InnerWriter).ToString();
return value;
}