AI OnAI Off
You can render your viewmodel in MVC, http://jondjones.com/learn-episerver-cms/episerver-developers-guide/episerver-customizing-episervers-ui/how-to-manually-render-a-episerver-page-or-block-using-net
public static class RenderControllerManually { public static string Render(int pageId, IEpiserverDependencies epiServerDependencies) { var viewModel = CreatePageTypesViewModel(pageId, epiServerDependencies); var viewDataDictionary = new ViewDataDictionary(viewModel); var controller = new ContentPageController(); var controllerName = GetControllerName(controller); var routeData = new RouteData(); routeData.Values.Add("Action", "Index"); routeData.Values.Add("controller", controllerName); var siteUrl = EPiServer.Configuration.Settings.Instance.SiteUrl.ToString(); var httpContext = new HttpContext( new HttpRequest(string.Empty, siteUrl, string.Empty), new HttpResponse(TextWriter.Null)); var controllerContext = new ControllerContext { RouteData = routeData, Controller = controller, HttpContext = new HttpContextWrapper(httpContext) }; var viewResult = ViewEngines.Engines.FindPartialView(controllerContext, "~/Views/Pages/ContentPage/index.cshtml"); using (var stringWriter = new StringWriter()) { var viewContext = new ViewContext(controllerContext, viewResult.View, viewDataDictionary, new TempDataDictionary(), stringWriter); viewResult.View.Render(viewContext, stringWriter); return stringWriter.ToString(); } } private static string GetControllerName(ContentPageController controller) { var controllerName = controller.GetType().Name; var index = controllerName.IndexOf("Controller"); return index < 0 ? controllerName : controllerName.Remove(index, "Controller".Length); } private static ContentPageViewModel CreatePageTypesViewModel(int pageId, IEpiserverDependencies epiServerDependencies) { var repository = ServiceLocator.Current.GetInstance<IContentRepository>(); var contentReference = new ContentReference(pageId); var contentPage = repository.Get<ContentPage>(contentReference); return new ContentPageViewModel(contentPage, epiServerDependencies); }
I missed the point from your question "This is for a web form based project", Can you please let us know, which cms version you are using
Hello,
For some weid reason of acheiving SPA concept on couple of page types. I wanted to achieve the following ,If yes how
Note:
Any pointer or suggestion
Thanks,
Amol Mahul