Back to Blog
Showhide navlink5/18/2023 ![]() Inside it, there are two components: Found and NotFound. We see the Router component that handles all the routing logic in our application. If we take a look at the Solution Explorer window, we are going to find the App.razor file. We can see there is no component related to our route but, the application still shows a component with the generic message. Let’s start our application one more time and as soon as it starts, let’s try to navigate to localhost:5001/something: App.razor File and the NotFound Component Without it, the application will report an error:įrom this message, it is pretty obvious what the compiler is complaining about. And if we add /index to it, the route will work as well:Īll routes must start with the / sign. We can start the application and it will navigate to the localhost:5001 route. ![]() Let’s try that by adding a new route in the Index component: "/index" The component is not restricted to only one routing rule, we can add multiple rules as well. From the previous articles, we could’ve seen that as soon as we start our application, it navigates to and shows the Index page. For the Index page, the route is /, which means it is the starting point for our application (the root). So, let’s inspect this directive by opening the Index.razor file:Īs you can see, if we want to set up the route in the component, we have to use the directive followed by the route itself. With it, we define the routes for our components. In the Blazor application, we can set up the Blazor routing rules using the directive. These rules help us define which component should appear for the required URL. To be able to create the routes in our application, we have to use the routing rules. To download the source code for this article, you can visit the Blazor Routing repository.įor the complete navigation for this series, you can visit the Blazor Series page.
0 Comments
Read More
Leave a Reply. |