/// <summary> /// Compiles and executes view template. /// </summary> /// <returns>Rendered result.</returns> public string Execute() { try { using (DataContext dataContext = new DataContext(Database, razorEngine: DataContextEngine, exceptionHandler: ExceptionHandler)) { if ((object)PagedViewModelDataType != null && (object)PagedViewModelHubType != null) { dataContext.ConfigureView(PagedViewModelDataType, PagedViewModelHubType, null as string, m_viewBag); } m_viewBag.AddValue("DataContext", dataContext); return(m_razorEngine.RunCompile(TemplateName, ModelType, Model, m_viewBag)); } } catch (Exception ex) { string errorTemplateName = WebServerOptions?.ErrorTemplateName; if (string.IsNullOrWhiteSpace(errorTemplateName)) { throw; } return(RenderErrorTemplate(errorTemplateName, ex)); } }
/// <summary> /// Compiles and executes view template. /// </summary> /// <returns>Rendered result.</returns> public string Execute() { using (DataContext dataContext = new DataContext(Database, razorEngine: DataContextEngine, exceptionHandler: ExceptionHandler)) { if ((object)PagedViewModelDataType != null && (object)PagedViewModelHubType != null) { dataContext.ConfigureView(PagedViewModelDataType, PagedViewModelHubType, null as string, m_viewBag); } m_viewBag.AddValue("DataContext", dataContext); return(m_razorEngine.RunCompile(TemplateName, ModelType, Model, m_viewBag)); } }