예제 #1
0
        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();
        }
예제 #2
0
        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());
        }