In Blazor, we can directly assign the route to each page on the razor itself. (that's the fun part doing) but I want to navigate to "/error" or "/404" page when any non-existing url is entered. Please Help me how we can get 404 status and implement the redirection. as it is an important task for SEO purpose.
ive tried many solutions: 1: i have created a component "error.razor" and added that component in app.razor inside the notfound section. in this scenario i am getting a 200 status code with same non-existing url in address bar 2: for a forceful redirection, i have injected NavigationManager in the "error.razor", with the help of NavigationManager i am redirecting it to 404 page. and i.e. a 302 redirection.
Edit: I am trying to get 400 status code on non-existing page. but i am getting 200. how can i get proper 400 error status in network panel. Help me on that.
FYR : Correct url
help me out if you have any solution.
You can write a custom
NotFoundPage
component that will display what you want the user to see when they navigate to a page that does not exist and put it under NotFound Context inapp.razor