Our current application is now running on ASP.NET Core (MVC) and I was wondering is there will be an offical way to use MVC and Blazor (client side) in the same project?
The reason why I want to do that is because we won't be able to migrated from MVC to Blazor in one big bang since, the application is just too big. I was thinking on a step by step transition from MVC to Blazor. Just not sure if this will be possible?
Blazor applications are component-based. Blazor components can be used in existing ASP.NET MVC applications.
You can add support for Pages to any ASP.NET Core MVC app by simply adding a Pages folder and adding Razor Pages files to this folder.
Razor components can be integrated into Razor Pages and MVC apps in a hosted Blazor WebAssembly solution. When the page or view is rendered, components can be prerendered at the same time.
This is definitely now possible for server-side Blazor, Chris Sainty's blog (and the source for the example in that blog) gives an example of exactly how to do that.
Personally I prefer to have the Blazor components in a separate project in the same solution as the MVC project. There are a few reasons for that:
I tend to do the initial debugging with the Blazor project set as the startup project and then switch to the MVC project when I'm ready to integrate the component into an MVC page.
If you want to try that approach, my answer to the question Adding Server-Side Blazor to an existing MVC Core app gives a complete walk through of how to add a separate Blazor project to an existing solution that contains an MVC project, and then how to use those Blazor components in the MVC project.
I expect very similar approaches would apply for client-side Blazor too, but I haven't tried that yet.
According to ASP.NET Core 3.0 Preview 2 release notes
Currently you cannot use Blazor
directly with ASP.NET Core MVC but you can use with newly introduced Razor Component. Microsoft is expecting using Blazor
directly with ASP.NET Core MVC will be possible in the upcoming versions of ASP.MET Core.
For more details: ASP.NET Core updates in .NET Core 3.0 Preview 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With