Without seeing my code, I canβt say what is going wrong, but after looking at the source for RazorViewEngine , I think there may be an idea that you are not doing it.
Here's what the CreateView method looks like:
protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) { var view = new RazorView(controllerContext, viewPath, layoutPath: masterPath, runViewStartPages: true, viewStartFileExtensions: FileExtensions, viewPageActivator: ViewPageActivator) { DisplayModeProvider = DisplayModeProvider }; return view; }
You can see that they pass true in for the runViewStartPages argument in the RazorView constructor. Looking at the source of the RenderView method in the RazorView class shows that this boolean parameter is used to create StartPageLookupDelegate , which is responsible for finding the _ViewStart file and compiling it into the execution hierarchy.
WebPageRenderingBase startPage = null; if (RunViewStartPages) { startPage = StartPageLookup(webViewPage, RazorViewEngine.ViewStartFileName, ViewStartFileExtensions); } webViewPage.ExecutePageHierarchy(new WebPageContext(context: viewContext.HttpContext, page: null, model: null), writer, startPage);
So, this means that you are probably doing one of two things:
- Overriding the
CreateView RazorViewEngine method and not initializing a RazorView described above. - Overriding the
RenderView RazorView method without creating StartPageLookupDelegate and passing it to the ExecutePageHierarchy method.
We hope this helps you find the right way to find a solution!
source share