Open
Description
Fix the last row in scenario matrix: #62153.
Internally, we are able to inform NavigationManager
about the route to NotFoundPage
:
// CustomRouter.cs
[Inject] private NavigationManager NavigationManager { get; set; }
public Type NotFoundPage { get; set; } = default!;
public async Task SetParametersAsync(ParameterView parameters)
{
if (NotFoundPage != null)
{
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)
{
throw new InvalidOperationException($"The type {NotFoundPage.FullName} " +
$"does not have a {typeof(RouteAttribute).FullName} applied to it.");
}
var routeAttribute = (RouteAttribute)routeAttributes[0];
if (routeAttribute.Template != null)
{
NavigationManager.NotFoundPageRoute = routeAttribute.Template;
}
}
}
Custom routers don't have access to internal NavigationManager.NotFoundPageRoute
. Change it, possibly to subscription to NotFound
event in Invoker and passing the information though it.