Reputation: 5048
Is it possible to render blazor component as string so I can render static HTML. I know where is a way to render MVC view to string. What I need to do is to make a way to create static HTML page that will be downloaded to WPF application where user can then open it in browser? This is popular answer for MVC app: How to render an ASP.NET MVC view as a string? So is there anything similar for Blazor? I don't need to do it in Blazor but web is done in Blazor so it would be nice.
Upvotes: 3
Views: 3724
Reputation: 308
From Blazor .Net 5 RC1 https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-5-release-candidate-1/#blazor-webassembly-prerendering
in your hosting app you can use component tag helper with render-mode="Static"
or render-mode="WebAssemblyPrerendered"
@page "/static-counter"
@namespace Server.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<component type="typeof(Client.Shared.MyComponent)" render-mode="WebAssemblyPrerendered" />
Upvotes: 2