{"record":{"id":"9d798e9a7c1550a8","repo":"dotnet/aspnetcore","slug":"setting-notfound-and-notfoundpage-properties-simul","errorCode":null,"errorMessage":"Setting NotFound and NotFoundPage properties simultaneously is not supported. Use either NotFound or NotFoundPage.","messagePattern":"Setting NotFound and NotFoundPage properties simultaneously is not supported\\. Use either NotFound or NotFoundPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Routing/Router.cs","lineNumber":143,"sourceCode":"        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)\n            {\n                throw new InvalidOperationException($\"The type {NotFoundPage.FullName} \" +\n                    $\"does not have a {typeof(RouteAttribute).FullName} applied to it.\");\n            }\n\n            var routeAttribute = (RouteAttribute)routeAttributes[0];\n            if (routeAttribute.Template != null)\n            {","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/Routing/Router.cs#L125-L161","documentation":"Thrown in Router.SetParametersAsync when both NotFound (the deprecated RenderFragment) and NotFoundPage (the newer Type-based property) are set. They are two ways to specify 404 content and the Router cannot honor both, so simultaneous use is rejected to avoid ambiguous behavior.","triggerScenarios":"A <Router> that declares both <NotFound>...</NotFound> and NotFoundPage=\"@typeof(MyNotFound)\". Migrating from the old NotFound API to NotFoundPage and leaving the old block in place.","commonSituations":"Following an upgrade/migration guide that recommends NotFoundPage but forgetting to remove the existing <NotFound> template; copy-paste between sample projects that use different APIs.","solutions":["Choose one API: keep NotFoundPage and delete the <NotFound> template, or remove NotFoundPage and keep <NotFound>.","Prefer NotFoundPage (NotFound is [Obsolete]) for new code.","Rebuild after removing one to confirm the error clears."],"exampleFix":"<!-- before -->\n<Router AppAssembly=\"@typeof(Program).Assembly\" NotFoundPage=\"@typeof(NotFound)\">\n    <NotFound><p>Not found</p></NotFound>\n</Router>\n\n<!-- after -->\n<Router AppAssembly=\"@typeof(Program).Assembly\" NotFoundPage=\"@typeof(NotFound)\">\n</Router>","handlingStrategy":"validation","validationCode":"// Set exactly one of NotFound or NotFoundPage. Prefer NotFoundPage for new code.\n@if (UseNotFoundPage) {\n    <Router AppAssembly=\"@typeof(Program).Assembly\" Found=\"@Found\" NotFoundPage=\"@typeof(NotFound)\" />\n} else {\n    <Router AppAssembly=\"@typeof(Program).Assembly\" Found=\"@Found\">\n        <NotFound><p>Not found</p></NotFound>\n    </Router>\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["During migration from NotFound to NotFoundPage, remove the old <NotFound> template in the same change.","Do not copy <NotFound> from an old sample when adopting NotFoundPage.","Treat NotFound as obsolete; prefer NotFoundPage going forward."],"tags":["blazor","routing","router","notfound","migration","configuration"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}