Microsoft Considering New Client-Side Hosting – Visual Studio Magazine
information
Containerized Blazor: Microsoft mulls new client-side hosting
Microsoft is exploring built-in container support for client-side Blazor WebAssembly applications.
The initial phase of the survey included Twitter questions related to feature requests on the company’s developer community feedback site.
The question goes something like this: “If you’re doing #Blazor Wasm projects that aren’t hosted by aspnet, how are you hosting them? Does this work for you – comment on this question and what you expect from Blazor Wasm containerization projects?
The tweet points to a “Docker support for the Blazor WASM project” feature request on the feedback site, which was posted on October 27 by Microsoft’s Brady Gaster. It says:
For most web projects, you can right-click the project and select Add Docker Support. The “Add Docker Support” flyout is missing for Blazor WASM standalone projects. If we could:
- Add Docker support to the Blazor WASM project and put in a base package that can serve WASM applications. We can use a simple nginx container or a pre-bult Kestrel image.
- Adds a popup menu for Blazor WASM projects, which when clicked will put a “Host Project”, so someone starting a WASM project can add a host after the fact and it will be pre-connected to serve the WASM application.
Heuer’s tweet on the same day was aimed at soliciting more feedback, but only received responses from a few developers, one of whom noted that such apps could be hosted as static web pages.Tag Heuer responded: “Yes (note: I work on this team and help deliver tools 🙂). But if anyone wants to do it (for their reasons) I’m soliciting [sic] what they expected. ”
In fact, it was Heuer himself who wrote the 2020 article “Hosting Blazor WebAssembly (Preview) in Azure Static Web Apps”.
The static site feature was actually proposed last year on the developer community site, where a post titled “Visual Studio support for creating, debugging, and deploying applications to Azure Static Web Apps” has been placed on the Visual Studio Roadmap middle.
Otherwise, there is no valid feedback on Heuer’s post or the October 27th Developer Community post.
As for the ASP.NET Core Blazor hosting models, prior to ASP.NET Core 6.0, they included Blazor Server and Blazor WebAssembly, the latter for browser-based client-side applications. In ASP.NET Core 6, Blazor Hybrid was added, where Razor components run directly in a native application (instead of WebAssembly) along with any other .NET code, and render HTML and CSS-based web UI natively to Embedded WebView Control Interop Channel, Microsoft said.
Outside of ASP.NET Core, other hosting models are scarce and unofficial.
However, among the many individual projects trying to containerize Blazor applications, there is one from Blazor expert Chris Sainty: “Containerizing Blazor WebAssembly Applications”. It was followed by his project to containerize the Blazor Server application. He said that while creating a dockerfile for a Blazor server application is straightforward, it’s not the case on the client side.
“Blazor WebAssembly projects present a different challenge for us, and they generate static files at release time,” he said. “Unlike Blazor Server applications, we don’t need the ASP.NET Core runtime to serve them. This means we can remove the ASP.NET Core runtime Docker image we used in Part 1 as a part of our final image Basics. So how do we deliver our files? The answer is NGINX.
He explained that the free and open-source nginx web server can also be used as a reverse proxy, load balancer and HTTP cache, serving static content quickly while using significantly less memory and being able to handle multiple Up to four times the number of requests per second.
Additionally, Nginx was proposed as an answer to a problem faced by a developer who couldn’t get the “Blazor client in a Docker container” to work and asked for help on the Microsoft Learn site. The accepted answer to this question includes the following (no need to edit): “The blazer web assembly application is a static website. It needs a web server to host it. So to deploy to a docker container, you need to choose a web server that supports container (usually ngnix) and copy the wwwroot folder to the location folder defined in the webserver.”
As mentioned above, nginx is proposed along with Kestrel and other options as part of a potential solution supported by Microsoft.
Add right-click Docker for Blazor WebAssembly apps in Visual Studio, based on tepid feedback received in Heuer’s tweet (two developers, one off-topic) and developer community post (zero developers) Support doesn’t seem to be a huge issue in the ranks, so Microsoft probably won’t do anything about it at all. Stay tuned to find out.
About the author
David Ramel is an editor and writer for Converge360.