{"record":{"id":"5bea4b2290f771ec","repo":"dotnet/aspnetcore","slug":"the-nameof-router-component-requires-a-value-fo-5bea4b","errorCode":null,"errorMessage":"The {nameof(Router)} component requires a value for the parameter {nameof(Found)}.","messagePattern":"The (.+?) component requires a value for the parameter (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Routing/Router.cs","lineNumber":135,"sourceCode":"        }\n    }\n\n    /// <inheritdoc />\n    public async Task SetParametersAsync(ParameterView parameters)\n    {\n        parameters.SetParameterProperties(this);\n\n        if (AppAssembly == null)\n        {\n            throw new InvalidOperationException($\"The {nameof(Router)} component requires a value for the parameter {nameof(AppAssembly)}.\");\n        }\n\n        // Found content is mandatory, because even though we could use something like <RouteView ...> as a\n        // reasonable default, if it's not declared explicitly in the template then people will have no way\n        // to discover how to customize this (e.g., to add authorization).\n        if (Found == null)\n        {\n            throw new InvalidOperationException($\"The {nameof(Router)} component requires a value for the parameter {nameof(Found)}.\");\n        }\n\n        if (NotFoundPage != null)\n        {\n#pragma warning disable CS0618 // Type or member is obsolete\n            if (NotFound != null)\n            {\n                throw new InvalidOperationException($\"Setting {nameof(NotFound)} and {nameof(NotFoundPage)} properties simultaneously is not supported. Use either {nameof(NotFound)} or {nameof(NotFoundPage)}.\");\n            }\n#pragma warning restore CS0618 // Type or member is obsolete\n            if (!typeof(IComponent).IsAssignableFrom(NotFoundPage))\n            {\n                throw new InvalidOperationException($\"The type {NotFoundPage.FullName} \" +\n                    $\"does not implement {typeof(IComponent).FullName}.\");\n            }\n\n            var routeAttributes = NotFoundPage.GetCustomAttributes(typeof(RouteAttribute), inherit: true);\n            if (routeAttributes.Length == 0)","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Routing/Router.cs#L117-L153","documentation":"Router requires a Found render fragment so that successful route matches always render through user-defined markup (this also documents the customization point for things like authorization). If Found is null at parameter-set time the Router throws InvalidOperationException, because there is no reasonable default that would also be discoverable. The check fires after the AppAssembly check.","triggerScenarios":"Declaring <Router> without a <Found> child template. Also by manually setting Router parameters and omitting Found, or binding Found to a fragment that is null.","commonSituations":"Trimming App.razor down during scaffolding and dropping the <Found> block; refactoring render fragments into code-behind and leaving the property null; copy-pasting a Router from a sample that used a different child structure.","solutions":["Add a <Found Context=\"routeData\"> ... </Found> child to the Router that renders a <RouteView RouteData=\"@routeData\" />.","Confirm the Found attribute (if used via code-behind) is assigned a non-null RenderFragment<RouteData>.","Use the standard Blazor template shape as the starting point.","If you want custom not-found behavior, set NotFoundPage or NotFound separately, but Found is still mandatory."],"exampleFix":"// before\n<Router AppAssembly=\"@typeof(Program).Assembly\">\n    <NotFound><p>Not found</p></NotFound>\n</Router>  <!-- missing Found -->\n// after\n<Router AppAssembly=\"@typeof(Program).Assembly\">\n    <Found Context=\"routeData\">\n        <RouteView RouteData=\"@routeData\" DefaultLayout=\"@typeof(MainLayout)\" />\n    </Found>\n    <NotFound><p>Not found</p></NotFound>\n</Router>","handlingStrategy":"validation","validationCode":"// Ensure the Found template is set; in markup this is structural. Programmatic check:\nif (router.Found is null)\n    throw new InvalidOperationException(\"Router.Found render fragment is required.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include <Found Context=\"routeData\"> ... </Found> inside <Router>.","Render <RouteView RouteData=\"@routeData\" /> inside Found.","Use the Blazor project template's App.razor as a starting point.","Add a smoke test that the app renders its home route."],"tags":["blazor","routing","router","configuration","renderfragment","invalidoperationexception"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}