Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] Preview9 - MapFallbackToClientSideBlazor unusable with MapBlazorHub() #13742

Closed
Daddoon opened this issue Sep 5, 2019 · 2 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly question

Comments

@Daddoon
Copy link

Daddoon commented Sep 5, 2019

Describe the bug

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() in preview8, the application don't instanciate any App component from the client-side project at startup.

It just keep showing "loading..."

To Reproduce

Steps to reproduce the behavior:

  1. Create a Blazor WASM application, ASP.NET Core Hosted checked
  2. In the server-side project, in ConfigureServices in Startup.cs, add services.AddServerSideBlazor();
  3. In Configure use:
app.UseClientSideBlazorFiles<ClientApp.Startup>();

app.UseEndpoints(endpoints =>
{
	endpoints.MapBlazorHub();
	endpoints.MapFallbackToClientSideBlazor<ClientApp.Startup>("server_index.html");
});
  1. 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

  2. Launch the server-side app in Debug. It is stuck on "loading..."

Expected behavior

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.

Additional info

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:

  • Copy index.html file with MSBuild, to server_index.cshtml, still on client-side project
  • Decorate the file with the "guessed" C# code and component type for startup like expected on a server-side project.
  • Set the file Property action to "None"
  • Add the file as a Link reference on any server-side project in a Pages folder, with Property action to "Included" (Contenu in French)
  • Call MapFallback to this file, like a regular server-side App starting page.

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.

@Daddoon Daddoon changed the title [Preview9] MapFallbackToClientSideBlazor unusable with new MapBlazorHub() definition [Blazor] Preview9 - MapFallbackToClientSideBlazor unusable with MapBlazorHub() Sep 5, 2019
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Sep 5, 2019
@mkArtakMSFT
Copy link
Member

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.

@Daddoon
Copy link
Author

Daddoon commented Sep 6, 2019

Thanks for your quick reply. I will stand with my MSBuild task then.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly question
Projects
None yet
Development

No branches or pull requests

2 participants