ASP.NET Blazor, what is it?

Posted: (EET/GMT+2)

 

Microsoft has been experimenting with a new web UI framework called Blazor. The current experimental release is version 0.7.0 (published about three weeks ago). The idea is simple but ambitious: run .NET code directly in the browser via the WebAssembly technology. It's quite surprising that WebAssembly is so little known.

Nonetheless, Blazor applications are built with Razor components (.razor files, aka "CSHTML"), and the runtime compiles your C# code into WebAssembly binary code so the browser can execute it without plugins or transpilation.

Some key points at this stage:

  • It is still experimental, so APIs can and will change.
  • You write UI components in C# instead of JavaScript (!).
  • Routing, dependency injection, and layout concepts come from ASP.NET Core.
  • The tooling experience is not super-great yet, but steadily improving.

A simple Blazor component looks like this:

@page "/hello"

Hello from Blazor

The time is @DateTime.Now.ToLongTimeString()

Even in its early state, it is an interesting look at where client-side .NET development may be heading. The ecosystem is growing, and it is already possible to build small interactive applications entirely in C#.