-
Notifications
You must be signed in to change notification settings - Fork 648
Conversation
…mplement error 404 handling/pages.
…exception swallower.
I'm wondering if after this implementation it's still possible to navigate to a MVC route not specified in the Blazor Routing system itself. See: #1154 |
@vertonghenb This should still be possible as long as those routes are processed before the Blazor router tries to have them rendered as if they point to components, and/or if an MVC route will override a Blazor route. Will have to test this. |
@TheFanatr Alright, love the idea though! |
This looks like a good design to me. Thanks @TheFanatr! We'll need to add one or more E2E tests like the other router E2E tests. If you're interested in adding that please go ahead and we might be able to merge this sooner. No worries if not, as I'll add them in a week or two when I get to merging this. |
Thanks. I'll look into the E2E tests, but may not end up actually making them before you do. |
@SteveSandersonMS I added an E2E test called |
@danroth27 I added a component called |
@SteveSandersonMS should I migrate this to the Razor Components section of the ASP.NET Core repo? |
I've created a pull request on the main repo now. |
Closing in favour of dotnet/aspnetcore#4376 |
I've talked about this here.
Essentially, this pull request contains a very simple error 404 handling implementation that allows users to set a fallback route for the blazor routing system to use if the no components are found for the requested route. This is a essentially a catch-all-nonexistent routing handler, where the rendering of the page body is "soft-redirected" to the component represented by the fallback route. The value is set in the
App.cshtml
file or wherever the router is defined.If
FallbackRoute
is null (unset), or also points to a nonexistent component, the regular behaviour will be observed, with the only difference being that the exception thrown will say that the routercannot find any component with the fallback route '/<fallback>'
if the fallback route is also nonexistent.The URI displayed by the browser does not change to represent the fallback route in order to allow the fallback component to implement JavaScript interop for handling specific URIs differently, such as the URI for a page that was moved.