Book Image

Blazor WebAssembly by Example

By : Toi B. Wright
Book Image

Blazor WebAssembly by Example

By: Toi B. Wright

Overview of this book

Blazor WebAssembly makes it possible to run C# code on the browser instead of having to use JavaScript, and does not rely on plugins or add-ons. The only technical requirement for using Blazor WebAssembly is a browser that supports WebAssembly, which, as of today, all modern browsers do. Blazor WebAssembly by Example is a project-based guide for learning how to build single-page web applications using the Blazor WebAssembly framework. This book emphasizes the practical over the theoretical by providing detailed step-by-step instructions for each project. You'll start by building simple standalone web applications and progress to developing more advanced hosted web applications with SQL Server backends. Each project covers a different aspect of the Blazor WebAssembly ecosystem, such as Razor components, JavaScript interop, event handling, application state, and dependency injection. The book is designed in such a way that you can complete the projects in any order. By the end of this book, you will have experience building a wide variety of single-page web applications with .NET, Blazor WebAssembly, and C#.
Table of Contents (11 chapters)

Why use JavaScript?

With Blazor WebAssembly, you can create complete applications without directly using JavaScript. However, you may need to use JavaScript because there are some scenarios that you cannot accomplish without it. Without JavaScript, you can't manipulate the DOM or call any of the JavaScript APIs that we rely on for web development.

This is a sample of the things that you do not have access to directly from the Blazor WebAssembly framework:

  • DOM manipulation
  • The Media Capture and Streams API
  • The WebGL API (2D and 3D graphics for the web)
  • The Web Storage API (localStorage and sessionStorage)
  • The Geolocation API
  • JavaScript pop-up boxes (alert, confirm, prompt)
  • The online status of the browser
  • The browser's history
  • Chart.js
  • Other third-party JavaScript libraries

The preceding list is not at all comprehensive since there are hundreds of JavaScript libraries that are currently available. However, the key point...