1 Starting your Blazor journey


This chapter covers

  • Reasons to choose Blazor for your next application
  • Why components are a better way to build UIs
  • Hosting models for Blazor

We live in exciting times, as .NET developers’ lives have never been better. We can create apps for any operating system, be it Windows, Linux, iOS, Android, or macOS, and of course, we can build amazing web-based applications with ASP.NET MVC, Razor Pages, and Web API, which have allowed us to create robust scalable and reliable systems for years.

However, there has long been a missing piece to the puzzle. One thing all of ASP.NET’s web solutions have in common is that they are server based. We’ve never been able to leverage the power of C# and .NET to write client-side web applications; this has always been the domain of JavaScript—but not anymore.

In this chapter, I’m going to introduce you to a revolutionary client-side framework called Blazor. Built on web standards, Blazor allows us to write rich, engaging user interfaces using C# and .NET. We’ll explore how Blazor can make your development process more efficient and raise your productivity levels, especially if you’re using .NET on the server as well. We’ll cover hosting models, an important concept to understand when starting out with Blazor. Next, we’ll begin to explore components and the benefits of using them to build UIs. Finally, we’ll discuss the reasons why you should consider Blazor for your next project.

1.1 Why choose Blazor for new applications?

1.2 Components, a better way to build UI

1.2.1 What is a component?

1.2.2 The benefits of a component-based UI

1.2.3 Anatomy of a Blazor component

1.3 Blazor, a platform for building modern UIs with C#

1.3.1 Understanding hosting models

1.3.2 Blazor WebAssembly

1.3.3 Blazor Server

1.3.4 Other hosting models