Search code examples
blazorblazor-server-sideblazor-client-sideasp.net-blazor

Blazor render-mode="Server" for displaying the component not working


I am trying to display a blazor component from a razor page by setting render-mode="Server" but it is not displaying the component. That is the below code is not working.

<component type="typeof(BlazorRC.Pages.SelectCity)" render-mode="Server" />

However when I change it to render-mode="ServerPrerendered" then the component displays. That is the below code works.

<component type="typeof(BlazorRC.Pages.SelectCity)" render-mode="ServerPrerendered" />

Why is this happening?? What should I do to make render-mode="Server" to work??


Solution

  • I solved this problem by adding blazor.server.js script link after calling the component in the Razor Page.

    <component type="typeof(BlazorRC.Pages.SelectCity)" render-mode="Server" />
    
    <script src="_framework/blazor.server.js"></script>
    

    Note that render-mode="ServerPrerendered" does not need the blazor.server.js.