Book Image

Building Blazor WebAssembly Applications with gRPC

By : Václav Pekárek
5 (1)
Book Image

Building Blazor WebAssembly Applications with gRPC

5 (1)
By: Václav Pekárek

Overview of this book

Building Blazor WebAssembly Applications with gRPC will take you to the next level in your web development career. After working through all the essentials of gRPC, Blazor, and source generators, you will be far from a beginner C# developer and would qualify as a developer with intermediate knowledge of the Blazor ecosystem. After a quick primer on the basics of Blazor technology, REST, gRPC, and source generators, you’ll dive straight into building Blazor WASM applications. You’ll learn about everything from two-way bindings and Razor syntax to project setup. The practical emphasis continues throughout the book as you steam through creating data repositories, working with REST, and building and registering gRPC services. The chapters also cover how to manage source generators, C# and debugging best practices, and more. There is no shorter path than this book to solidify your gRPC-enabled web development knowledge. By the end of this book, your knowledge of building Blazor applications with one of the most modern and powerful frameworks around will equip you with a highly sought-after skill set that you can leverage in the best way possible.
Table of Contents (10 chapters)

gRPC services in C#

Before we implement the gRPC service in our project, we need to understand how the implementation can be done in .NET projects in general.

Two ways of implementing

When we want to implement gRPC services in the .NET project, we have two options. The Code-First method, where we decorate the C# classes with attributes, and the standard way using .proto files. Let’s start with the Code-First method.

Code-First

This method uses C# contracts: classes and interfaces in C# with attribute decoration. The advantage of this approach is that you do not need to learn any language other than C# and if you already have defined your models and interfaces, you can just decorate them instead of creating new models.

The main disadvantage, however, is that this approach is only useful if you plan to stay in the .NET technologies and you do not need to share the gRPC service definitions with other languages.

The Code-First method requires a NuGet package called...