public static string RenderView(string viewPath, ControllerContext controllerContext, ViewDataDictionary viewData) { StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); var dummyView = new DummyView() { ViewData = viewData }; var viewContext = new ViewContext(controllerContext, dummyView, viewData, new TempDataDictionary(), writer); var view = CreateView(controllerContext, viewPath, null); view.Render(viewContext, writer); return sb.ToString(); }
public static string RenderView(string viewPath, ControllerContext controllerContext, ViewDataDictionary viewData) { StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); var dummyView = new DummyView() { ViewData = viewData }; var viewContext = new ViewContext(controllerContext, dummyView, viewData, new TempDataDictionary(), writer); var view = CreateView(controllerContext, viewPath, null); view.Render(viewContext, writer); return(sb.ToString()); }