Skip to content

[Components] Simple 404 Handling (Fallback Route) #4376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

TheFanatr
Copy link

This is a migration of Blazor pull request 1534. I have talked about it there and it has been reviewed. I simply applied the same changes to the refactored sources in this repo. Essentially, it enables simple error 404 handling that causes another (fallback) component to render if no components were found for a requested route. Please visit the aforementioned link for more details.

@TheFanatr
Copy link
Author

The CI build seems to have failed for unrelated reasons as far as I can tell.

@SteveSandersonMS
Copy link
Member

Moving to #4794, so I can make a further tweak to change the parameter to be the actual component type, rather than a route string. This is to make it more strongly-typed.

@TheFanatr
Copy link
Author

I agree that strong-typing is good in most cases, and recognize that this has already been merged now, but I'd still like to make the argument for a route string in this case. Being able to define a fallback route instead of just a component allows for the specification of parameters as well as a component type implicitly, meaning that in theory, a generic error page could simply be created with a parameter for error type, which would be set to 404 if used as a fallback route, or any other error if routed to by another component. I realize that this may not actually be that common a scenario, and that most people would prefer to just have a 404 component, but I think it is worth mentioning. Also, keeping it as a simple route allows for the functionality to be expanded into supporting routing to an MVC page, a static asset, or even another website as a fallback, though this wasn't supported initially anyways. Either way, thanks for merging.

@SteveSandersonMS
Copy link
Member

You can still do all that. The fallback component can read the URL and use any logic to act on it (including rendering another component or performing a full page reload to a server-side endpoint).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants