dotnet/aspnetcore · error · InvalidOperationException
The Router component requires a value for the parameter AppA
Error message
The Router component requires a value for the parameter AppAssembly.
What it means
Thrown in Router.SetParametersAsync. AppAssembly (marked [EditorRequired]) is the assembly the Router scans for [Route]/@page components. If it is null after parameters are set, the Router has nothing to scan and cannot build a route table, so it refuses to render.
Source
Thrown at src/Components/Components/src/Routing/Router.cs:127
_locationAbsolute = NavigationManager.Uri;
NavigationManager.LocationChanged += OnLocationChanged;
NavigationManager.OnNotFound += OnNotFound;
RoutingStateProvider = ServiceProvider.GetService<IRoutingStateProvider>();
if (HotReloadManager.IsSupported)
{
HotReloadManager.Default.OnDeltaApplied += ClearRouteCaches;
}
}
/// <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 obsoleteView on GitHub (pinned to 294cab2f9b)
Solutions
- Set AppAssembly on the Router: <Router AppAssembly="@typeof(Program).Assembly">.
- If pages live in another assembly, also pass AdditionalAssemblies.
- For Blazor Web App with .Client project, point AppAssembly at the client project's assembly (e.g., @typeof(_Imports).Assembly or the client Program).
Example fix
<!-- before -->
<Router Found="@Found" NotFoundPage="@typeof(NotFound)">
<!-- after -->
<Router AppAssembly="@typeof(Program).Assembly"
Found="@Found" NotFoundPage="@typeof(NotFound)"> Defensive patterns
Strategy: validation
Validate before calling
// In App.razor, always set AppAssembly; guard against null at the markup level.
<Router AppAssembly="@(AppAssembly ?? throw new InvalidOperationException(nameof(Router.AppAssembly)))"
Found="@Found" ...>
@code { static Assembly AppAssembly => typeof(Program).Assembly; } Prevention
- Always set AppAssembly="@typeof(Program).Assembly" on <Router>.
- Treat AppAssembly as [EditorRequired]; the IDE warns if it is missing.
- When splitting Client/Server, confirm each Router points at the assembly containing its pages.
When it happens
Trigger: Rendering <Router> without an AppAssembly parameter, or binding it to a null expression. The standard usage is <Router AppAssembly="@typeof(Program).Assembly" ...>.
Common situations: A hand-written App.razor where AppAssembly was deleted or never added; binding AppAssembly to an expression that evaluates to null; splitting into Client/Server projects and forgetting to set AppAssembly on the Router in one of them.
Related errors
- The Router component requires a value for the parameter Foun
- Setting NotFound and NotFoundPage properties simultaneously
- The type {NotFoundPage.FullName} does not have a Microsoft.A
- The RouteView component requires a non-null value for the pa
- The following routes are ambiguous: '{existingText}' in '{ex
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/e9ef0c0f847dd2ca.
Report an issue: GitHub.