/// <summary> /// Renders the view and return the string output /// </summary> /// <returns></returns> public string Render() { RazorViewEngine viewEngine = new RazorViewEngine(); RazorView view = this.IsPartialView ? new RazorView(this.ControllerContext, this.TemplatePath, null, false, FileExtensions) : new RazorView(this.ControllerContext, this.TemplatePath, this.LayoutPage, true, FileExtensions); using (StringWriter writer = new StringWriter()) { ViewContext viewContext = new ViewContext(this.ControllerContext, view, ViewData, new TempDataDictionary(), writer); // render the view to StringWriter view.Render(viewContext, writer); viewEngine.ReleaseView(this.ControllerContext, view); return(writer.ToString()); } }
public void ReleaseView(ControllerContext controllerContext, IView view) { _viewEngine.ReleaseView(controllerContext, view); }