From Preview9, it seem impossible to load a valid application through MapFallbackToClientSideBlazor on a server-side project.
This method expect a filename that can be found in the client-side project, like index.html
But as the new MapBlazorHub does not accept any starting component anymore, like MapBlazorHub
It just keep showing "loading..."
Steps to reproduce the behavior:
app.UseClientSideBlazorFiles<ClientApp.Startup>();
app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub();
endpoints.MapFallbackToClientSideBlazor<ClientApp.Startup>("server_index.html");
});
Copy index.html in client-side, and past in the same folder with a name server_index.html, and replace in the file content, the blazor.webassembly.js reference, to blazor.server.js
Launch the server-side app in Debug. It is stuck on "loading..."
The application should launch normally, as we fallbacked on client-side files.
In my opinion, it is not working because the server-side implementation expect the component declaration in a _Host.cshtml file or similar, to be invoked with the Html helper since the deprecation of MapBlazorHub generic type declaration, but the client-side logic doesn't have any functionnality to cover this behavior at index.html level.
I was expecting to use this in order to have a similar startup file when having to switch between client-side and server-side implementations with my BlazorMobile plugin.
This way, being able to use some server-side code for debugging, sharing same html/js/css ressources on each implementations, and also switch easily without thinking between WASM runtime (for iOS, Android, UWP) and .NET Core one (for remote device debugging or Desktop with Electron.NET).
The strategy was only to copy/past the index.html file in server_index.html instead, through a MSBuild task, and replace the blazor.webassembly.js reference to blazor.server.js, and fallback on this file in server-side projects, it was a no brainer.
With this change, the only workaround i found and that i'm working on for the next release for preview9 is:
In my opinion it's a lot of overhead, in order to keep HTML/JS/CSS references synced between the two implementation, as i don't have found any alternative at this moment.
Thanks for contacting us, @Daddoon.
We've removed support for using Server-side blazor with static HTML partially because of security reasons.
At the moment client and server startups are somewhat different, which we plan to think about and potentially improve in the future.
Thanks for your quick reply. I will stand with my MSBuild task then.