コード例 #1
0
 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);
 }
コード例 #2
0
        public static string RenderView(string viewPath, object model = null, ControllerContext controllerContext = null)
        {
            var renderer = new RazorViewRenderer(controllerContext);

            return(renderer.RenderViewToString(viewPath, model));
        }