I have an existing .net core 3.1 MVC application that I've started adding Blazor components to. This is working great, the components render and work as expected. Currently to get to a page that uses Blazor I am adding a controller action and view which handles the routing then I add the component tag to the view to render the Blazor component.
So let's say I have a Customers Blazor component, which is really a customers "page", I do the following.
- Add a controller and action, in this example I would add a "Customers" controller with an "Index" action
- I add the corresponding Index view
- Create a Customers Blazor component in the Pages folder of my app
- In the view I use the component tag helper to load the Blazor component:
<component type="typeof(MyApp.Pages.Customers)" render-mode="Server" />
Like I said, all of this works just fine it's just a lot of overhead for every page I add that uses Blazor. It would be nice to be able to just use the built-in Blazor routing for pages. If this worked I could just add the Customers Blazor component in the Pages folder and add the @page tag like this:
@page "/Customers"
Unfortunately this does not work, I get a 404 if I try to use this method.
I have followed the instructions in this article but still receive a 404: https://docs.microsoft.com/en-us/aspnet/core/blazor/components/integrate-components?view=aspnetcore-3.1#use-routable-components-in-an-mvc-app
Has anyone got this working? Is it even possible?
Thanks!