public FrontViewResult(ControllerContext controllerContext, string fileExtension, string viewVirtualPath, string masterVirtualPath) { var templateEngine = TemplateEngines.GetEngineByFileExtension(fileExtension); this.View = templateEngine.CreateView(controllerContext, viewVirtualPath, masterVirtualPath); this.viewEngine = templateEngine.GetViewEngine(); }
protected static IHtmlString RenderViewInternal(HtmlHelper htmlHelper, string viewPath, ViewDataDictionary viewData, object model) { if (string.IsNullOrEmpty(viewPath)) { throw new ArgumentException("", "viewPath"); } ViewDataDictionary dictionary = null; if (model == null) { if (viewData == null) { dictionary = new ViewDataDictionary(htmlHelper.ViewData); } else { dictionary = new ViewDataDictionary(viewData); } } else if (viewData == null) { dictionary = new ViewDataDictionary(model); } else { dictionary = new ViewDataDictionary(viewData) { Model = model }; } StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); ViewContext viewContext = new ViewContext(htmlHelper.ViewContext, htmlHelper.ViewContext.View, dictionary, htmlHelper.ViewContext.TempData, writer); TemplateEngines.GetEngineByFileExtension(Path.GetExtension(viewPath)).CreateView(htmlHelper.ViewContext.Controller.ControllerContext, viewPath, null).Render(viewContext, writer); return(new HtmlString(writer.ToString())); }