Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Blazor WebAssembly by Example
  • Table Of Contents Toc
Blazor WebAssembly by Example

Blazor WebAssembly by Example - Third Edition

By : Toi B. Wright
close
close
Blazor WebAssembly by Example

Blazor WebAssembly by Example

By: Toi B. Wright

Overview of this book

Blazor WebAssembly allows you to build web apps without the need for JavaScript, plugins, or add-ons. With its continued growth in popularity, Blazor WebAssembly can open doors to new career paths and exciting projects, and Blazor WebAssembly by Example makes getting started easy. This project-based guide teaches you how to build single-page web applications by focusing heavily on the practical over the theoretical. The author provides step-by-step instructions for each project as well as a video of her following those exact steps. In this updated edition, we've added two new chapters on integrating artificial intelligence into web apps built with Blazor WebAssembly. You'll start with simple standalone web apps and gradually progress to hosted web applications with SQL Server backends. Each project covers a different concept from the Blazor WebAssembly ecosystem, such as Razor components, JavaScript interop, security, events, debugging, state management, hosted applications, REST APIs, and AI. The book's projects get more challenging as you progress, but you don't have to complete them in order, which makes this book a valuable resource for beginners as well as those who just want to dip into specific topics. By the end of this book, you'll be building your own web apps with .NET and C# using Blazor WebAssembly.
Table of Contents (18 chapters)
close
close
15
Chapter 15: Unlock Access to the Code Bundle and the PDF Version
16
Other Books You May Enjoy
17
Index

Blazor framework benefits

There are several benefits from using the Blazor framework. For starters, it is free and open source. So, there are no license fees, no paywalls, and no gimmicks. It is just you and a seriously powerful framework built on Microsoft's rock-solid .NET Core framework. Also, Blazor is a Single-Page Application (SPA) framework that uses Razor syntax to enable your web apps to run C# in the browser. You can build interactive, dynamic web apps without switching to JavaScript mode every five minutes. And with Microsoft's best-in-class tools like Visual Studio and VS Code, you've got everything you need to code smarter, faster, and cleaner. Finally, Microsoft is constantly improving the Blazor framework. They are adding new features, improving performance, and making your developer life easier with each release. Let's begin with the most fundamental advantage: Blazor is free and open source.

Free and open source

The Blazor framework will always be free and open source. It is part of the open source ASP.NET Core project that was originally developed by Microsoft. All the source code for Blazor is available on GitHub as part of the dotnet/aspnetcore repository, which is maintained by the .NET Foundation. The .NET Foundation is an independent, non-profit organization established to support the innovative, commercially friendly, open-source ecosystem around the .NET platform. The .NET platform has a strong community of developers who continue to contribute via pull requests under the MIT license.

This is a link to the dotnet/aspnetcore repository on GitHub: https://github.com/dotnet/aspnetcore. Blazor code lives in the src/Components folder.

Since ASP.NET Core is free and open source, Blazor is too. There are no fees or licensing costs associated with using Blazor. Everyone, including individuals, startups, and commercial enterprises, can use Blazor for free.

.NET Core framework

The Blazor framework is built on the .NET Core framework. Therefore, if you are familiar with the .NET Core framework, you can quickly become productive using the Blazor framework. That means you can leverage all your favorite libraries, NuGet packages, and design patterns. Also, since the code for both the client and server can be written in C#, the client and server can share code and libraries. Need to validate data the same way on both ends? No problem. Write it once, share it everywhere.

Blazor does not rely on plugins or recompiling the code into other languages. Instead, it is based on open web standards and is supported by all modern browsers, including mobile browsers.

SPA framework

As I mentioned earlier, Blazor is a SPA framework. As the name implies, a SPA framework is used to build web apps that load a single HTML page only once. In response to each UI update, the web app dynamically rewrites the areas of the page that have changed instead of reloading the entire page. This delivers fast, fluid transitions that mimic native mobile apps.

Here's how it works: When a page is rendered, Blazor creates a render tree that is a graph of the components on the page. It is like the Document Object Model (DOM) created by the browser. However, it is a virtual DOM. Updates to the UI are applied to the virtual DOM, and only the differences between the DOM and the virtual DOM are rendered by the browser. This approach delivers high performance by avoiding full page reloading, just like modern JavaScript frameworks.

Razor syntax

Razor syntax is the secret behind Blazor's magic. It lets you mix HTML markup with C# code in the same file. Razor syntax is the primary templating language powering the view engine in ASP.NET Core applications.

Blazor web apps are built using Razor components—reusable UI elements that bundle C# code, HTML markup, and other Razor components. They are quite literally the building blocks of the Blazor framework. For more information on Razor components, refer to Chapter 2, Building Your First Blazor WebAssembly Application.

Razor syntax is not exclusive to Blazor. Razor Pages and MVC also use Razor syntax. Unlike Razor Pages and MVC, which render the whole page, Razor components only render the DOM changes. The way to distinguish between them is that Razor components use the .razor file extension, while both MVC and Razor Pages use the .cshtml file extension.

The name of the Blazor framework has an interesting origin story. The name Blazor comes from Browser + Razor. This name captures Blazor's core innovation: client-side .NET execution using the Razor templating engine.

Awesome tooling

Great tooling matters. You can use either Microsoft Visual Studio, Microsoft Visual Studio Code, or a third-party editor like JetBrains Rider to develop Blazor applications. Microsoft Visual Studio is a full-featured integrated development environment (IDE), while Microsoft Visual Studio Code is a lightweight, yet powerful, cross-platform editor. Best of all, both options offer free versions, and both are incredible tools for building Blazor apps.

Supported by Microsoft

While other frameworks come and go, Blazor is here to stay. Although it's open source, Microsoft is still at the wheel. They continue to make large investments in the future of Blazor. The following list includes features that Microsoft is actively working on to improve Blazor:

  • AI-assisted development
  • Built-in AI components
  • Multithreading support
  • Integrated .NET Scaffolding tools
  • A smoother Getting Started workflow
  • Localized validation messages
  • A new Blazor Gateway for hosting Blazor WebAssembly apps in .NET Aspire

In short, when you build with Blazor, you're building on a foundation that's only getting stronger.

This is the link to the ASP.NET Core roadmap for .NET 11 that includes Blazor-specific work items: https://github.com/dotnet/aspnetcore/issues/64787. As you can see, Microsoft is continuing to make major investments in Blazor.

There are many benefits associated with using the Blazor framework to develop web applications. Blazor gives you the freedom of open source, the strength of .NET, the speed of SPAs, the simplicity of Razor syntax, the power of Microsoft's tooling, and the confidence of ongoing support.

Those benefits matter, but Blazor also comes in several flavors, each representing a different hosting model suited to specific scenarios.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Blazor WebAssembly by Example
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon