{"record":{"id":"5b2a659ef517de09","repo":"dotnet/aspnetcore","slug":"the-type-context-handler-fullname-does-not-imple","errorCode":null,"errorMessage":"The type {context.Handler.FullName} does not implement {typeof(IComponent).FullName}.","messagePattern":"The type (.+?) does not implement (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Routing/Router.cs","lineNumber":265,"sourceCode":"            _renderHandle.Render(Found(endpointRouteData));\n\n            if (ComponentsActivitySource.IsSupported && _renderHandle.ComponentActivitySource != null)\n            {\n                _renderHandle.ComponentActivitySource.StopNavigateActivity(activityHandle, null);\n            }\n            return;\n        }\n\n        RefreshRouteTable();\n\n        var context = new RouteContext(locationPath);\n        Routes.Route(context);\n\n        if (context.Handler != null)\n        {\n            if (!typeof(IComponent).IsAssignableFrom(context.Handler))\n            {\n                throw new InvalidOperationException($\"The type {context.Handler.FullName} \" +\n                    $\"does not implement {typeof(IComponent).FullName}.\");\n            }\n\n            activityHandle = RecordDiagnostics(context.Handler.FullName, context.Entry.RoutePattern.RawText);\n\n            Log.NavigatingToComponent(_logger, context.Handler, locationPath, _baseUri);\n\n            var routeData = new RouteData(\n                context.Handler,\n                context.Parameters ?? _emptyParametersDictionary);\n\n            _renderHandle.Render(Found(routeData));\n\n            // If you navigate to a different path, then after the next render we'll update the scroll position\n            if (relativePath != _updateScrollPositionForHashLastLocation)\n            {\n                _updateScrollPositionForHashLastLocation = relativePath.ToString();\n                _updateScrollPositionForHash = true;","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Routing/Router.cs#L247-L283","documentation":"At navigation time the Router resolves the location against its route table; if a handler matches but that handler type does not implement IComponent, the router throws InvalidOperationException before attempting to render. This is the runtime counterpart to the constructor-time RouteData check — it catches corruption introduced between table construction and navigation, e.g. by a route keying bug or a stray entry from a non-component assembly.","triggerScenarios":"A route context whose Handler is set to a type that is not a component — typically because route discovery picked up an attribute on a non-component type, or because route table entries were mutated. Fires inside the navigation path after Routes.Route(context) resolves a handler.","commonSituations":"Custom route providers or IRouteDefinitionResolver implementations that emit entries for non-component types; assembly scanning that included MVC controllers or Razor Pages models decorated with a compatible attribute; a stale route table after hot-reload of a type into a non-component form.","solutions":["Audit the assemblies contributing routes; ensure only Blazor components are registered as handlers.","Inspect the named type in the exception — if it is a controller or model, exclude that assembly from the Router's AdditionalAssemblies or filter the [Route] contributor.","If you provide custom route entries, gate them on typeof(IComponent).IsAssignableFrom(handler).","Clear route caches after a hot-reload that changes a type's base hierarchy."],"exampleFix":"// before — custom route provider registers a non-component\nentries.Add(new InboundRouteEntry { Handler = typeof(UserApi), ... });\n// after\nif (typeof(IComponent).IsAssignableFrom(typeof(UserPage)))\n    entries.Add(new InboundRouteEntry { Handler = typeof(UserPage), ... });","handlingStrategy":"type-guard","validationCode":"// Guard custom route providers before adding entries.\nif (!typeof(IComponent).IsAssignableFrom(context.Handler))\n    throw new InvalidOperationException($\"{context.Handler} is not a component; refusing to register.\");","typeGuard":"static bool IsRouteHandler(Type t) => typeof(IComponent).IsAssignableFrom(t);","tryCatchPattern":null,"preventionTips":["Filter all route-discovery scans by typeof(IComponent).IsAssignableFrom(t).","Exclude MVC/controller assemblies from Router.AdditionalAssemblies.","After hot-reload, clear route caches if a type's hierarchy changed.","Add a startup test that loads the route table and asserts every handler is a component."],"tags":["blazor","routing","router","navigation","icomponent","invalidoperationexception"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}