dotnet/aspnetcore · error · InvalidOperationException

The {nameof(Router)} component requires a value for the para

Error message

The {nameof(Router)} component requires a value for the parameter {nameof(Found)}.

What it means

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.

Source

Thrown at src/Components/Components/src/Routing/Router.cs:135

        }
    }

    /// <inheritdoc />
    public async Task SetParametersAsync(ParameterView parameters)
    {
        parameters.SetParameterProperties(this);

        if (AppAssembly == null)
        {
            throw new InvalidOperationException($"The {nameof(Router)} component requires a value for the parameter {nameof(AppAssembly)}.");
        }

        // Found content is mandatory, because even though we could use something like <RouteView ...> as a
        // reasonable default, if it's not declared explicitly in the template then people will have no way
        // to discover how to customize this (e.g., to add authorization).
        if (Found == null)
        {
            throw new InvalidOperationException($"The {nameof(Router)} component requires a value for the parameter {nameof(Found)}.");
        }

        if (NotFoundPage != null)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            if (NotFound != null)
            {
                throw new InvalidOperationException($"Setting {nameof(NotFound)} and {nameof(NotFoundPage)} properties simultaneously is not supported. Use either {nameof(NotFound)} or {nameof(NotFoundPage)}.");
            }
#pragma warning restore CS0618 // Type or member is obsolete
            if (!typeof(IComponent).IsAssignableFrom(NotFoundPage))
            {
                throw new InvalidOperationException($"The type {NotFoundPage.FullName} " +
                    $"does not implement {typeof(IComponent).FullName}.");
            }

            var routeAttributes = NotFoundPage.GetCustomAttributes(typeof(RouteAttribute), inherit: true);
            if (routeAttributes.Length == 0)

View on GitHub (pinned to 3600ca084e)

Solutions

  1. Add a <Found Context="routeData"> ... </Found> child to the Router that renders a <RouteView RouteData="@routeData" />.
  2. Confirm the Found attribute (if used via code-behind) is assigned a non-null RenderFragment<RouteData>.
  3. Use the standard Blazor template shape as the starting point.
  4. If you want custom not-found behavior, set NotFoundPage or NotFound separately, but Found is still mandatory.

Example fix

// before
<Router AppAssembly="@typeof(Program).Assembly">
    <NotFound><p>Not found</p></NotFound>
</Router>  <!-- missing Found -->
// after
<Router AppAssembly="@typeof(Program).Assembly">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
    </Found>
    <NotFound><p>Not found</p></NotFound>
</Router>
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the Found template is set; in markup this is structural. Programmatic check:
if (router.Found is null)
    throw new InvalidOperationException("Router.Found render fragment is required.");

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11). Data as JSON: /api/errors/5bea4b2290f771ec. Report an issue: GitHub.