Deep Dive into Blazor – Visual Studio Magazine

Questions and answers

Q&A: Deep dive into Blazor

The “hottest” project in the Microsoft-centric web development space is Blazor, which offers both a server-side component and a client-side component based on the revolutionary WebAssembly technology, combining to provide a C# instead of JavaScript.

The free and open source framework has evolved from its web orientation to target other domains including mobile and even desktop.

Officially, Microsoft says:

Blazor apps are composed of reusable web UI components implemented using C#, HTML, and CSS. Client and server code is written in C#, allowing you to share code and libraries.

Blazor is a feature of ASP.NET, the popular web development framework that extends the .NET development platform with tools and libraries for building web applications.

With its growing popularity in the Microsoft dev camp, it’s no surprise that it’s getting an in-depth feature preview at the upcoming Visual Studio Live! conference scheduled for June 13-17, 2022 in Austin, Texas.

Directing the deep dive is Rockford Lhotka, a well-known open source and distributed systems architect, author, and speaker. We caught up with “Rocky” for a short Q&A to learn more about his presentation which will teach attendees:

  • How Blazor, WebAssembly, and .NET combine to enable this app platform
  • How to Build Server-Side Blazor and Blazor WebAssembly Apps
  • How to use Blazor UI framework features such as UI components, data binding, routing, and authorization

Visual Studio Magazine: From its roots as Steve Sanderson’s pet project, Blazor has become hugely popular. Besides allowing C# coders to participate in the web development action instead of relying primarily on traditional JavaScript, what else does Blazor offer to explain this popularity?
Lhotka: Blazor provides a number of powerful features in addition to allowing C# developers to use their language of choice for web development.

“Blazor provides a number of powerful features in addition to allowing C# developers to use the language of their choice for web development.”

Rockford Lhotka, Chief Software Architect, Marimer LLC

Blazor supports running your code on the server or on the client through WebAssembly, and you can choose which users or devices get which experience. For example, you can direct users with older, less powerful devices to use server-side Blazor, and users with modern devices to use Blazor WebAssembly.

Blazor also includes a powerful UI component model, based on learnings from previous UI frameworks such as MVC, Web Forms, Windows Forms, WPF, and Xamarin. The Blazor UI Component model makes it easy to create highly maintainable and reusable UI components surrounding a single UI widget or entire sections of app functionality. Coupled with the simple yet extremely powerful data-binding capabilities supported by Blazor, the result is a UI template designed for building enterprise-level applications down to a simple web page.

ASP.NET Core MVC is also less dependent on JavaScript than other alternative frameworks. Does Blazor offer advantages over ASP.NET Core MVC, or are they specific tools for different types of work?
ASP.NET Core MVC is a server-side web framework, with roots dating back to the days before what we now think of as the modern web. For some application scenarios, a server-based model that pushes HTML, CSS, and JavaScript to the browser is still very valid. This is especially true for scenarios where data display is important and user interactivity is of secondary importance.

For applications where user interactivity is very important, most people prefer UI frameworks like Angular, React, or Blazor. All of these tools provide the ability to create rich user experiences, though none are as good at displaying raw data as something like MVC.

The advantage of Blazor in this case is that you can mix ASP.NET MVC or Razor Pages functionality with your Blazor functionality in the same app and using the same IDE and programming language.

Since its initial focus on SPA apps, Blazor WebAssembly has been aimed at all sorts of other targets, from mobile to even desktop. Is there a limit to this? Why not Blazor for everything?
WebAssembly itself is likely to be a transformative technology for many types of applications, as it runs in all modern browsers and in a growing number of server-side and IoT scenarios, including places like Kubernetes. The ability to write code in the language of your choice, such as C#, Go, Rust, or many others – and compile that code to WebAssembly so it can run in many environments – is extremely convincing.

Blazor WebAssembly itself is a UI framework focused on leveraging HTML and CSS, along with your C# code (instead of TypeScript or JavaScript) to build browser-based apps. As with other SPA technologies, Blazor benefits greatly from the expansion of browser-based hybrid scenarios for hosting on mobile and desktop apps, as well as directly in a browser experience.

What all of these have in common is that the browser sandbox remains in place. That’s good, because it means Blazor WebAssembly apps can be run in your browser or as a mobile or desktop app with the same security and trust you have with apps written in other tools that target the browser, such as Angular or React.

On the other hand, it is often more cost effective to build very high fidelity mobile applications using more native technologies than browser-based technologies. If you’re building a consumer-facing mobile or desktop app that’s a primary touchpoint for your brand, obviously it’s critical that your users get the best possible experience, which is what drives most organizations to build iOS and Android apps. native, or perhaps to use a cross-platform tool like Xamarin/MAUI or Flutter.

Do organizations typically combine Blazor Server and Blazor WebAssembly functionality in their development, or did you find one or the other more important?
From my observations, many organizations use server-side Blazor with the understanding that if they need the scalability provided by Blazor WebAssembly, they can adopt this model in the future. Slightly fewer organizations build Blazor WebAssembly apps out of the box, and a minority build their apps to dynamically switch between the two models at runtime.

What about performance? How does Blazor compare to alternative frameworks like React and others?
When talking about Blazor performance, it is necessary to separate server-side Blazor from Blazor WebAssembly.

Server-side Blazor is extremely capable, with performance largely based on ensuring your web server is sufficient for the workload. The software architecture behind server-side Blazor is extremely similar to the proven designs used by VT or 3270 terminals of yore, but with modern internet speeds and server hardware.

Blazor WebAssembly, or any WebAssembly-based UI, can be slower than JavaScript UI frameworks like React. This is because WebAssembly does not yet allow native code to interact directly with the HTML DOM. Interaction with UI elements must therefore go through a JavaScript shim. Pure computational code tends to be faster in WebAssembly than in JavaScript, but UI interactions are slower.

You have to temper this with the understanding that when used correctly, all of these SPA UI frameworks, including Blazor WebAssembly, can create top-notch user experiences that are very satisfying to use.


What innovations do you see coming for Blazor and its client-side technology, WebAssembly?


I can’t wait for WebAssembly to embrace multi-threading and have the ability for native wasm code to interact directly with the HTML DOM. I’m also extremely excited about how WebAssembly is spreading beyond the browser, with the potential to become a common assembly language for client, servers, IoT devices and more.

Blazor is poised to support multithreading, and with its tight integration with the MAUI framework, Blazor is likely to become a major technology for building apps that run in browsers, on mobile devices, and on desktops. desktop, all based on the same C#, HTML and CSS code base.

About the Author


David Ramel is an editor and writer for Converge360.



Comments are closed.