Asp.Net MVC Adding Blazor Server
Overview
Walk through taking an existing asp.net mvc app and adding server side blazor support.
Pre-requisits
- an existing asp.net mvc app running .net 5
New files
_Imports.razor
default using statements for blazor components
App.razor
blazor routing
Pages/Counter.razor
blazor component
Changed files
startup.cs
add blazor server side (no default blazor routing as routing handled by mvc)
Index.cshtml
add blazor component to existing mvc view
Notes
- this post demonstrates adding a blazor component to an existing mvc view page
- original mvc code base is mvc visual studio template
- additional code comes from blazor server side visual studio template
- this is not client side blazor aka wasm
- watch out for casing; blazor components must start capitalized
Code links
- repo: https://github.com/andyTheCoder/asp-net-mvc-add-blazor-server
- commit with all required changes: https://github.com/andyTheCoder/asp-net-mvc-add-blazor-server/commit/d54f696553c4f0bb588400e3fa1f5298678fe737
References
Read other posts