public static string RenderView(string viewPath, object model, ControllerContext controllerContext, out string errorMessage) { errorMessage = null; try { var renderer = new RazorViewRenderer(controllerContext); return(renderer.RenderViewToString(viewPath, model)); } catch (Exception ex) { errorMessage = ex.GetBaseException().Message; } return(null); }
public static string RenderView(string viewPath, object model = null, ControllerContext controllerContext = null) { var renderer = new RazorViewRenderer(controllerContext); return(renderer.RenderViewToString(viewPath, model)); }