{"record":{"id":"cb1b5be1224f2658","repo":"OrchardCMS/OrchardCore","slug":"0-1-must-not-be-empty-at-least-one-2-is-required-to-locate-a","errorCode":null,"errorMessage":"'{0}.{1}' must not be empty. At least one '{2}' is required to locate a view for rendering.","messagePattern":"'(.+?)\\.(.+?)' must not be empty\\. At least one '(.+?)' is required to locate a view for rendering\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.DisplayManagement/Razor/RazorShapeTemplateViewEngine.cs","lineNumber":81,"sourceCode":"            var viewData = new ViewDataDictionary(viewContext.ViewData);\n            viewData.TemplateInfo.HtmlFieldPrefix = displayContext.HtmlFieldPrefix;\n\n            var htmlHelper = MakeHtmlHelper(viewContext, viewData);\n            return htmlHelper.PartialAsync(viewName, displayContext.Value);\n        }\n        else\n        {\n            return RenderRazorViewAsync(viewName, displayContext);\n        }\n    }\n\n    private async Task<IHtmlContent> RenderRazorViewAsync(string viewName, DisplayContext displayContext)\n    {\n        var viewEngines = _options.Value.ViewEngines;\n\n        if (viewEngines.Count == 0)\n        {\n            throw new InvalidOperationException(string.Format(\"'{0}.{1}' must not be empty. At least one '{2}' is required to locate a view for rendering.\",\n                typeof(MvcViewOptions).FullName,\n                nameof(MvcViewOptions.ViewEngines),\n                typeof(IViewEngine).FullName));\n        }\n\n        var viewEngine = viewEngines[0];\n\n        var result = await RenderViewToStringAsync(viewName, displayContext.Value, viewEngine);\n\n        return new HtmlString(result);\n    }\n\n    public async Task<string> RenderViewToStringAsync(string viewName, object model, IViewEngine viewEngine)\n    {\n        var actionContext = await _httpContextAccessor.HttpContext.GetActionContextAsync();\n        var view = FindView(actionContext, viewName, viewEngine);\n\n        using var output = new ZStringWriter();","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.DisplayManagement/Razor/RazorShapeTemplateViewEngine.cs#L63-L99","documentation":"RazorShapeTemplateViewEngine renders shape templates through Razor views using the first IViewEngine registered in MvcViewOptions.ViewEngines. If the ViewEngines collection is empty there is no engine to locate the view, so the method throws InvalidOperationException. This indicates the MVC view-engine configuration is broken or was cleared.","triggerScenarios":"MvcViewOptions.ViewEngines has no registered view engines at the time a Razor-based shape template is rendered — e.g. custom startup code removed the default RazorViewEngine, or MVC view services were not configured for the tenant.","commonSituations":"Custom module startup replacing/clearing view engine registrations; misconfigured tenant pipeline that skips AddViews/AddMvc conventions; a stripped-down host missing OrchardCore.Mvc conventions.","solutions":["Ensure the application/tenant calls the Orchard Core MVC conventions (AddOrchardCore().AddMvc()) so RazorViewEngine is registered","Remove any code that clears MvcViewOptions.ViewEngines","Register at least one IViewEngine via services.Configure<MvcViewOptions>(o => o.ViewEngines.Add(...))","Check per-tenant Startup modules so the tenant enabling the shape rendering has the MVC feature enabled"],"exampleFix":"// before\nservices.Configure<MvcViewOptions>(o => o.ViewEngines.Clear());\n// after\nservices.AddOrchardCore().AddMvc(); // keeps default RazorViewEngine registered","handlingStrategy":"validation","validationCode":"var viewEngines = serviceProvider.GetRequiredService<IOptions<MvcViewOptions>>().Value.ViewEngines;\nif (viewEngines.Count == 0) { throw new InvalidOperationException(\"No IViewEngine registered; enable Orchard Core MVC conventions.\"); }","typeGuard":null,"tryCatchPattern":"try { await shapeRender; } catch (InvalidOperationException e) when (e.Message.Contains(\"must not be empty\")) { /* fix startup config */ }","preventionTips":["Never clear MvcViewOptions.ViewEngines in custom startup","Enable the MVC feature/conventions for every tenant that renders shapes","Add integration coverage that renders at least one Razor shape template"],"tags":["razor","view-engines","configuration","mvc"],"backgroundTag":"missing-required-config","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"}