Beginners Guide to Blazor

For those of you who are not familiar with the term “Blazor”, Blazor is a single-page application (SPA) framework built on .NET that is based on C#, Razor, and HTML that runs in the web browsers (Client-side) via WebAssembly. Blazor was designed to simplify the task of building fast single-page applications. Blazor is still experimental and not yet officially released.

So now that we answered the very basic question about what is blazor, let’s try to answer most of the questions regarding Blazor.

Why would I use .NET for web development?

Using .NET in the browser offers many advantages that can help make web development easier and more productive:

  • Stable and consistent: .NET offers standard APIs, tools, and build infrastructure across all .NET platforms that are stable, feature rich, and easy to use.
  • Modern innovative languages: .NET languages like C# and F# make programming a joy and keep getting better with innovative new language features.
  • Industry leading tools: The Visual Studio product family provides a great .NET development experience on Windows, Linux, and macOS.
  • Fast and scalable: .NET has a long history of performance, reliability, and security on the server. Using .NET as a full-stack solution makes it easier to scale your apps.

How can you run .NET in a web browser?

Running .NET in the browser is made possible by a relatively new standardized web technology called WebAssembly. WebAssembly is a “portable, size- and load-time-efficient format suitable for compilation to the web.” Code compiled to WebAssembly can run in any browser at native speeds. To run .NET binaries in a web browser, we use a .NET runtime (specifically Mono) that has been compiled to WebAssembly

Does Blazor compile my entire .NET-based app to WebAssembly?

No, a Blazor app consists of normal compiled .NET assemblies that are downloaded and run in a web browser using a WebAssembly-based .NET runtime. Only the .NET runtime itself is compiled to WebAssembly. 

Wouldn't the app download size be huge if it also includes a .NET runtime?

Not necessarily. .NET runtimes come in all shapes in sizes. Early Blazor prototypes used a compact .NET runtime (including assembly execution, garbage collection, threading) that compiled to a mere 60KB of WebAssembly. Blazor now runs on Mono, which is currently significantly larger. However, opportunities for size optimization abound, including merging and trimming the runtime and application binaries. Other potential download size mitigations include caching and using a CDN.

What features will Blazor support?

Blazor will support all of the features of a modern single-page app (SPA) framework:

  • A component model for building composable UI
  • Routing
  • Layouts
  • Forms and validation
  • Dependency injection
  • Live reloading in the browser during development
  • Server-side rendering
  • JavaScript interop
  • Full .NET debugging both in browsers and in the IDE
  • Rich IntelliSense and tooling
  • Publishing and app size trimming

Can I use Blazor without running .NET on the server?

Yes, a Blazor app can be deployed as a set of static files without the need for any .NET support on the server.

Can I use Blazor with ASP.NET Core on the server?

Yes! Blazor optionally integrates with ASP.NET Core to provide a seamless and consistent full-stack web development solution.

Is this Silverlight all over again?

No, Blazor is a .NET web framework based on HTML and CSS that runs in the browser using open web standards. It doesn’t require a plugin, and it works on mobile devices and older browsers.

Does Blazor use XAML?

No, Blazor is a web framework based on HTML, CSS, and other standard web technologies.

Is WebAssembly supported in all browsers?

Yes, WebAssembly has achieved cross-browser consensus and all modern browsers now support WebAssembly.

Does Blazor work on mobile browsers?

Yes, modern mobile browsers also support WebAssembly.

Can I use existing JavaScript libraries with Blazor?

Yes, Blazor apps can call into JavaScript through JavaScript interop APIs.

Where did the name "Blazor" come from?

Blazor makes heavy use of Razor, a markup syntax for HTML and C#. Browser + Razor = Blazor! 

Leave a Reply

Close Menu