dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.06k stars 9.9k forks source link

Blazor WebAssembly: Prerendering As Static Files and Rehydration #48810

Open MichaelPeter opened 1 year ago

MichaelPeter commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

I want to publish my Blazor Web App to to Azure Static Files, but I still want the instant response of an prerenered page, without requiring an active server.

Thats why I want to publish the Prerendered Static Page as an Build Output html/js file, which is initally instantly loaded, while the WebAssembly Part loads in the background and Rehydrates the Page after beeing loaded

I need this because either my Website gets too few hits and I don't have the budget for an active non serverless Blazor Server or the Page gets too many Hits (or needs unlimited scaling) with little budget for ever individual user. Also If I use Edge Environments for Global availablity in every Region I would need a own active server, instead of just some file storage in every region.

Site with Little Hits

Site With Lots Of Hits (But Low Budget Per User)

I want to build an active page which has lots of hits and should still load fast.

Site which are globally available on Edge Environments

I want my site to be available globally with fast access times and instant loads. In this case I would have to have on every continent/availabilty zone an active blazor server. By having static files, I just need a static file server for my application in every region.

Current status

Right now Blazor United / Web Assembly is not suited for interactive serverless instant response sites. For this scenario I only have the option to switch to svelte / preact, vanilla javascipt. But these options make complex interactive applications more difficult.

Downsides:

I am aware that this way the webpage is not adaptive, or only adaptive with javascript parts that load with the precompiled files / adaptivness through css.

Describe the solution you'd like

There is a .csproj property or an dotnet run command which allows to generate a single precompiled js file (Or html+js file) which contain the prerendered html.

This precompiled file then can be included in the index.html of the webassembly app and Blazor rehydrates it.

Additional context

No response

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Xyncgas commented 1 year ago

I heard it would be possible in .NET 8 https://youtu.be/pJGDPEk45Jc?t=1099

I don't understand why microsoft would be so good to implement this feature, if people are serving static html they are not using azure, why would the .NET developers do something that let people take the html files generated by ASP.NET and host it somewhere else without benefiting microsoft's eco system

Maybe, there is truely hope in this land of the free and plenty

OskarKlintrot commented 9 months ago

@Xyncgas Azure have Static Web Apps which is free or cheap, depending on your needs.

ghost commented 8 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

wonsil commented 7 months ago

Thanks @javiercn. I could not find the dup by that title.

wonsil commented 7 months ago

Bringing comment from closed issue here:

Blazor is almost the full web UI stack. It is missing the static site, which is popular with SMBs and developers who host these workloads on IIS, Azure Static Websites, and GitHub Pages. It would be useful to teach new web developers Razor syntax and the component model which would prepare them for more advanced rendering models in Blazor. Until then, we are ceding this portion of the market to markdown and JavaScript frameworks which may lure developers away from ever learning Blazor technology.

MichaelPeter commented 6 months ago

@dotnet-policy-bot looks like this is an error by the bot since it is not a pull request?