{"record":{"id":"292f2e70376566ec","repo":"OrchardCMS/OrchardCore","slug":"unable-to-find-view-viewname-the-following-locations-were","errorCode":null,"errorMessage":"Unable to find view '{viewName}'. The following locations were searched:","messagePattern":"Unable to find view '(.+?)'\\. The following locations were searched:","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.DisplayManagement/Razor/RazorShapeTemplateViewEngine.cs","lineNumber":139,"sourceCode":"    {\n        var getViewResult = viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: true);\n        if (getViewResult.Success)\n        {\n            return getViewResult.View;\n        }\n\n        var findViewResult = viewEngine.FindView(actionContext, viewName, isMainPage: true);\n        if (findViewResult.Success)\n        {\n            return findViewResult.View;\n        }\n\n        var searchedLocations = getViewResult.SearchedLocations.Concat(findViewResult.SearchedLocations);\n        var errorMessage = string.Join(\n            System.Environment.NewLine,\n            new[] { $\"Unable to find view '{viewName}'. The following locations were searched:\" }.Concat(searchedLocations));\n\n        throw new InvalidOperationException(errorMessage);\n    }\n\n    private IHtmlHelper MakeHtmlHelper(ViewContext viewContext, ViewDataDictionary viewData)\n    {\n        if (_htmlHelper is IViewContextAware contextAwareHelper)\n        {\n            var newViewContext = new ViewContext(viewContext, viewContext.View, viewData, viewContext.Writer);\n            contextAwareHelper.Contextualize(newViewContext);\n        }\n\n        return _htmlHelper;\n    }\n}\n","sourceCodeStart":121,"sourceCodeEnd":153,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.DisplayManagement/Razor/RazorShapeTemplateViewEngine.cs#L121-L153","documentation":"When the underlying view engine cannot locate the Razor view for a shape template, RazorShapeTemplateViewEngine aggregates every searched location into one message and throws InvalidOperationException. The shape's template view simply does not exist in any of the module/theme view locations searched.","triggerScenarios":"Rendering a shape whose template view name (from the shape type, template alternates, or ShapeTemplateViewEngine conventions) matches no .cshtml file in any active module or theme; missing view compiled into the module assembly.","commonSituations":"Typo in shape type or template name; template .cshtml not added as embedded/compiled Razor view; alternates pointing to a template that was renamed; view placed in wrong folder path (Views/Items-foo.cshtml conventions); theme override missing after switching themes.","solutions":["Create the missing view at one of the listed searched locations (examine the error message paths)","Fix the shape type/template name or alternate naming to match an existing .cshtml","Ensure the .cshtml is included in the module project (RazorSdk compiles it) and the module is enabled","If overriding in a theme, place the override at the exact convention path the engine searches"],"exampleFix":"// before\n// shape type: MyWidget, but only Views/MyWidgety.cshtml exists\n// after\n// add src/My.Module/Views/MyWidget.cshtml so FindView resolves it","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { html = await displayManager.RenderAsync(shape); } catch (InvalidOperationException e) when (e.Message.StartsWith(\"Unable to find view\")) { _logger.LogError(e, \"Shape template missing\"); html = HtmlString.Empty; }","preventionTips":["Keep shape template names aligned with shape types and alternates conventions","Ensure .cshtml templates are part of the compiled module project","Read the searched-locations list in the message to place views correctly","Test theme overrides so paths match the engine's search conventions"],"tags":["razor","view-not-found","shapes","templates"],"backgroundTag":"file-not-found","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}