Skip to content

Commit 6da74c7

Browse files
committed
Path from args has higher priority than NotFoundPage.
1 parent f842fcf commit 6da74c7

File tree

1 file changed

+9
-8
lines changed
  • src/Components/Components/src/Routing

1 file changed

+9
-8
lines changed

src/Components/Components/src/Routing/Router.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,18 @@ private void OnNotFound(object sender, NotFoundEventArgs args)
394394
bool renderContentIsProvided = NotFoundPage != null || args.Path != null;
395395
if (_renderHandle.IsInitialized && renderContentIsProvided)
396396
{
397-
Log.DisplayingNotFound(_logger);
398-
if (NotFoundPage == null && !string.IsNullOrEmpty(args.Path))
397+
if (!string.IsNullOrEmpty(args.Path))
399398
{
400399
// The path can be set by a subscriber not defined in blazor framework.
401400
_renderHandle.Render(builder => RenderComponentByRoute(builder, args.Path));
402-
return;
403401
}
404-
405-
// Having the path set signals to the endpoint renderer that router handled rendering.
406-
args.Path = _notFoundPageRoute;
407-
RenderNotFound();
402+
else
403+
{
404+
// Having the path set signals to the endpoint renderer that router handled rendering.
405+
args.Path = _notFoundPageRoute;
406+
RenderNotFound();
407+
}
408+
Log.DisplayingNotFound(_logger, args.Path);
408409
}
409410
}
410411

@@ -490,7 +491,7 @@ private static partial class Log
490491
internal static partial void NavigatingToExternalUri(ILogger logger, string externalUri, string path, string baseUri);
491492

492493
[LoggerMessage(4, LogLevel.Debug, $"Displaying {nameof(NotFound)} on request", EventName = "DisplayingNotFoundOnRequest")]
493-
internal static partial void DisplayingNotFound(ILogger logger);
494+
internal static partial void DisplayingNotFound(ILogger logger, string displayedPath);
494495
#pragma warning restore CS0618 // Type or member is obsolete
495496
}
496497
}

0 commit comments

Comments
 (0)