Replies: 2 comments
-
Hey @mifopen I've explored this (and some of the issues you raise) in a couple of blog posts... https://jonhilton.net/blazor-wasm-prerendering/ I believe this is the "right" way to handle Blazor WASM prerendering (but that's speculation on my part, informed by scraping together information from various MS blog posts etc.) The bit I'm now exploring is how to make Azure B2C auth work properly when prerendering this way :-) |
Beta Was this translation helpful? Give feedback.
-
Regarding prerendering Blazor WebAssembly: Sharing Dependency Injection (DI) between server-side and client-side: Additionally, if you're interested in further optimizing your web crawling efforts, you might explore integrating Crawlbase into your project. It offers powerful web crawling capabilities, potentially enhancing your application's functionality and performance. |
Beta Was this translation helpful? Give feedback.
-
It almost works after the following steps:
blazorwasm
template app._Hosted.cshtml
fromblazorserver
template to thePages
folder.endpoints.MapFallbackToFile("index.html")
toendpoints.MapFallbackToPage("/_Host")
inStartup.cs
of the server<script src="_framework/blazor.server.js"></script>
to<script src="_framework/blazor.webassembly.js"></script>
in_Host.cshtml
Now if you
dotnet run
the server you will be able to navigate template pages with prerendered HTML.But, I have two questions:
/
and then going to/fetchdata
everything will be fine, but if you then use F5 (e.g refresh) on/fetchdata
path, you will seeTo fix it you need to copy
HttpClient
configuration code from Client/Program.cs to Server/Startup.csBeta Was this translation helpful? Give feedback.
All reactions