{"record":{"id":"fbec70d524fb3bb3","repo":"dotnet/aspnetcore","slug":"unable-to-find-the-provided-template-template","errorCode":null,"errorMessage":"Unable to find the provided template '{template}'","messagePattern":"Unable to find the provided template '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Routing/RouteTableFactory.cs","lineNumber":190,"sourceCode":"        var templates = GetTemplates(pageType);\n        var result = ComputeTemplateGroupInfo(templates);\n\n        RoutePattern? parsedTemplate = null;\n        HashSet<string>? routeParameterNames = null;\n        for (var i = 0; i < result.ParsedTemplates.Length; i++)\n        {\n            var (parsed, parameters) = result.ParsedTemplates[i];\n            if (string.Equals(parsed.RawText, template, StringComparison.OrdinalIgnoreCase))\n            {\n                parsedTemplate = parsed;\n                routeParameterNames = parameters;\n                break;\n            }\n        }\n\n        if (parsedTemplate == null)\n        {\n            throw new InvalidOperationException($\"Unable to find the provided template '{template}'\");\n        }\n\n        return new InboundRouteEntry()\n        {\n            Handler = pageType,\n            RoutePattern = parsedTemplate,\n            UnusedRouteParameterNames = GetUnusedParameterNames(result.AllRouteParameterNames, routeParameterNames!),\n        };\n    }\n    private static void DetectAmbiguousRoutes(TreeRouteBuilder builder)\n    {\n        var seen = new HashSet<InboundRouteEntry>(new InboundRouteEntryAmbiguityEqualityComparer());\n        seen.EnsureCapacity(builder.InboundEntries.Count);\n\n        for (var i = 0; i < builder.InboundEntries.Count; i++)\n        {\n            var current = builder.InboundEntries[i];\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Routing/RouteTableFactory.cs#L172-L208","documentation":"RouteTableFactory.GetEntry looks up a previously-parsed route template by its raw text among the templates derived from assembly scanning. If the requested template string does not case-insensitively equal any parsed template's RawText, the lookup fails and the factory throws InvalidOperationException. This indicates the caller asked for a template that was never registered as a [Route] on a component.","triggerScenarios":"Calling the internal RouteTableFactory with a template string that does not match any [Route(\"...\")] attribute present in the supplied assemblies. Common from hot-reload invalidation, programmatic route generation, or unit tests that pass arbitrary template strings.","commonSituations":"Adding a [Route] attribute with a typo and referencing the corrected string elsewhere; referencing a route that lives in an assembly not passed to the factory; renaming a route template in code but keeping the old string in a lookup table; multi-assembly apps where the route was contributed by an optional plugin that is not loaded.","solutions":["Confirm the template string exactly matches a [Route(...)] attribute in one of the assemblies supplied to RouteTableFactory (case-insensitive, including leading/trailing slashes).","Ensure the assembly containing the route is included in the AppAssembly / AdditionalAssemblies passed to the Router.","Search the codebase for [Route(\"<template>\")] to confirm the attribute exists and is spelled identically.","If the route is dynamic, register a matching template attribute on a component before requesting it."],"exampleFix":"// before — typo in requested template\nvar entry = factory.GetEntry(\"usrs/{id}\", pageType); // no [Route(\"usrs/{id}\")] exists\n// after\nvar entry = factory.GetEntry(\"users/{id}\", pageType); // matches [Route(\"users/{id}\")]","handlingStrategy":"validation","validationCode":"// Confirm a template is registered before requesting it from RouteTableFactory.\nbool IsRegistered(IEnumerable<string> templates, string requested)\n    => templates.Any(t => string.Equals(t, requested, StringComparison.OrdinalIgnoreCase));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Search the codebase for [Route(\"<template>\")] / @page \"<template>\" to confirm a template exists.","Include every assembly that declares routes in AppAssembly / AdditionalAssemblies.","Centralize template strings in a constants class to avoid drift.","Add a test that lists all expected templates and asserts each resolves."],"tags":["blazor","routing","route-template","routetablefactory","invalidoperationexception"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}