{"record":{"id":"569a109532439759","repo":"dotnet/aspnetcore","slug":"the-type-context-handler-fullname-does-not-imple","errorCode":null,"errorMessage":"The type {context.Handler.FullName} does not implement Microsoft.AspNetCore.Components.IComponent.","messagePattern":"The type (.+?) does not implement Microsoft\\.AspNetCore\\.Components\\.IComponent\\.","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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/Routing/Router.cs#L247-L283","documentation":"Thrown in Router.Refresh after a route matches: context.Handler is the type matched by the URL, but it does not implement IComponent. The Router only renders Blazor components, so a [Route]-decorated non-component type matched during navigation is a configuration error, not a renderable page.","triggerScenarios":"A type in AppAssembly (or AdditionalAssemblies) decorated with [Route(\"/path\")] but not implementing IComponent (e.g., an ASP.NET Core MVC/Razor Pages route attribute leaking into the Blazor-scanned assembly, or a class with [Route] by mistake). Navigating to that path triggers the throw.","commonSituations":"Mixing MVC [Route] and Blazor [Route] (Microsoft.AspNetCore.Mvc.Routing vs Microsoft.AspNetCore.Components) in the same assembly; an old Razor Pages/MVC handler left in an assembly scanned by the Blazor Router; a shared library referenced by both stacks.","solutions":["Identify the matched type from the exception (context.Handler.FullName) and remove its [Route] attribute or move it out of the Router-scanned assembly.","Make sure only Blazor components carry Microsoft.AspNetCore.Components.RouteAttribute in AppAssembly/AdditionalAssemblies.","If the type should be a Blazor page, make it implement IComponent (e.g., convert it to a .razor component with @page)."],"exampleFix":"// before: a non-component type in a Blazor-scanned assembly\n[Route(\"/legacy\")]\npublic class LegacyHandler { /* MVC-style, not IComponent */ }\n\n// after: move it out of the scanned assembly, or convert to a component\n// Legacy.razor\n@page \"/legacy\"","handlingStrategy":"validation","validationCode":"// Filter the assemblies the Router scans so only IComponent types with Components [Route] are matched.\nstatic IEnumerable<Type> BlazorRoutes(params Assembly[] assemblies) =>\n    assemblies.SelectMany(a => a.GetTypes())\n        .Where(t => typeof(IComponent).IsAssignableFrom(t))\n        .Where(t => t.GetCustomAttributes(typeof(RouteAttribute), true).Length > 0);\n// Ensure non-component [Route]-bearing types (MVC handlers, etc.) are not in AppAssembly/AdditionalAssemblies.","typeGuard":"static bool IsBlazorRoutable(Type t) =>\n    typeof(IComponent).IsAssignableFrom(t) &&\n    t.GetCustomAttributes(typeof(Microsoft.AspNetCore.Components.RouteAttribute), true).Length > 0;","tryCatchPattern":null,"preventionTips":["Keep MVC/Razor Pages [Route] attributes out of assemblies scanned by the Blazor Router.","Distinguish Microsoft.AspNetCore.Components.RouteAttribute from Microsoft.AspNetCore.Mvc.Routing.RouteAttribute when annotating types.","Add a startup test asserting every [Route] type in the scanned assemblies implements IComponent."],"tags":["blazor","routing","router","icomponent","routeattribute","type-conflict"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}