Aspnetcore: Make BlazorAppBuilderExtensions and hybrid scenario configurable

Created on 12 Feb 2018  路  5Comments  路  Source: dotnet/aspnetcore

Most of below relates to the hybrid scenario.

  1. I am assuming this is a limitation of this experimental release, but there should be a plan on initiating the blazor app from within a MVC view in a hybrid scenario?

Something like:
Home.cshtml in the server side MVC app would send <app>Loading...</app> which in turn would load the wasm etc instead of the need to have a separate html. Enables mixing server and client functionality on the same MVC app controlled page. Blazor TagHelper?

  1. Current BlazorAppBuildExtension is not configurable to take a specific URL it is supposed to serve on.

Make it possible to pass a specific URL\route.

Something like:
app.UseBlazor("HostedInAspNet.Client","/blazor");

or may be even better consider converting the above params into an options object. I was able to make this work by modifying the builderextension for now, but, an options object is the way to go?

  1. Consider passing information to the client app during init so that the client app boots with pre-init set of information.
area-blazor

Most helpful comment

We should consider eliminating the <script type='blazor-boot'>, and replacing it with a regular old reference to a .js file, e.g., <script src='_blazor/boot.js></script>. The contents of that file can be generated during build, so it contains all the necessary information that would previously have been on the blazor-boot tag.

This will make it much easier to use as part of server-generated pages from arbitrary server-side platforms.

All 5 comments

These are all interesting suggestions which we will consider. We probably won't get to them in the next couple of months but will do at some point. Thanks!

Let me know if would be interested in a PR at this point for 2. I have a working prototype for it up on https://github.com/muqeet-khan/Blazor/ without the options model.

@muqeet-khan For point 2, it's trivial to cover the server-side part of this by wrapping your UseBlazor call inside an app.Map call. We don't even need a new API for that. The trickier bit will be figuring out how this interacts with client-side routing. So for now I'd leave this, until we have the client-side routing bit in place.

We should consider eliminating the <script type='blazor-boot'>, and replacing it with a regular old reference to a .js file, e.g., <script src='_blazor/boot.js></script>. The contents of that file can be generated during build, so it contains all the necessary information that would previously have been on the blazor-boot tag.

This will make it much easier to use as part of server-generated pages from arbitrary server-side platforms.

In 0.5.0 we've done the thing proposed above - replacing <script type='blazor-boot'> with a plain normal .js script tag so it can be embedded into any HTML page, either static or server-generated. Hopefully that covers the necessary scenarios.

app.UseBlazor("HostedInAspNet.Client","/blazor")

This is handled using ASP.NET Core's app.Map etc.

Was this page helpful?
0 / 5 - 0 ratings