Learning Blazor

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Take advantage of your C# skills to build UI components and client-side experiences with .NET. With this practical guide, you’ll learn how to use Blazor WebAssembly to develop nextgeneration web experiences. Built on top of ASP.NET Core, Blazor represents the future of .NET single-page application investments. Author David Pine, who focuses on .NET and Azure content development at Microsoft, explains how WebAssembly enables many non-JavaScript-based programming languages to run on the client browser. In this book, you’ll learn about real-time web functionality with ASP.NET Core SignalR and discover strategies for bidirectional JavaScript interop. David also covers component data binding, hierarchical eventdriven communications, in-memory state management, and local storage. This book shows you how to: • Create a beautiful, feature-rich Blazor app • Develop and localize an enterprise-scale app using GitHub Actions and Azure Cognitive Services Translator • Create advanced validation scenarios for input-based components with forms • Automatically deploy and host to Azure Static Web Apps, and rely on HTTP services • Use a geolocation service and speech synthesis and recognition native to the browser • Author a custom modal verification mechanism for validating a user

Author(s): David Pine
Edition: 1
Publisher: O’Reilly Media, Inc.
Year: 2023

Language: English
Pages: 327

Cover
Table of Contents
Foreword
Preface
Why Blazor?
Who Should Read This Book
For .NET Developers
For Web Developers
Why I Wrote This Book
How to Use This Book
Roadmap and Goals of This Book
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Chapter 1. Blazing into Blazor
The Origin of Blazor
Blazor Hosting
Blazor Server
Blazor WebAssembly
Blazor Hybrid
Single-Page Applications, Redefined
Why Adopt Blazor
.NET’s Potential in the Browser
.NET Is Here to Stay
Familiarity
Safe and Secure
Code Reuse
Tooling
Open Source Software
Your First Blazor App with the .NET CLI
Build the App
Install Dev-cert
Run the App
The Code Must Live On
Perusing the “Learning Blazor” Sample App
Summary
Chapter 2. Executing the App
Requesting the Initial Page
App Startup and Bootstrapping
Blazor WebAssembly App Internals
Detecting Client Culture at Startup
Layouts, Shared Components, and Navigation
Summary
Chapter 3. ​​Componentizing
Design with the User in Mind
Leveraging “Pwned” Functionality
“Have I Been Pwned” Client Services
Restricting Access to Resources
The Introduction Component Says “Hi”
The Joke Component and Services
Aggregating Joke Services—Laughter Ensues
DI from Library Authors
Forecasting Local Weather
Summary
Chapter 4. Customizing the User Login Experience
A Bit More on Blazor Authentication
Client-Side Custom Authorization Message Handler Implementation
The Web.Client ConfigureServices Functionality
Native Speech Synthesis
Sharing and Consuming Custom Components
Chrome: The Overloaded Term
Modal Modularity and Blazor Component Hierarchies
Exploring Blazor Event Binding
Summary
Chapter 5. Localizing the App
What Is Localization?
The Localization Process
The Language Selection Component
Automating Translations with GitHub Actions
Localization in Action
Summary
Chapter 6. Exemplifying Real-Time Web Functionality
Defining the Server-Side Events
Exposing Twitter Streams and Chat Functionality
Writing Contextual RPC and Inner-Process Communication
Configuring the Hub Endpoint
Consuming Real-Time Data on the Client
Configuring the Client
Sharing a Hub Connection
Consuming Real-Time Data in Components
Summary
Chapter 7. Using Source Generators
What Are Source Generators?
Building a Case for Source Generators
C# Source Generators in Action
Source Generating the localStorage API
Source Generating the Geolocation API
Example Usage of the ILocalStorageService
Summary
Chapter 8. Accepting Form Input with Validation
The Basics of Form Submission
Framework-Provided Components for Forms
Models and Data Annotations
Defining Component Models
Defining and Consuming Validation Attributes
Implementing a Contact Form
Implementing Speech Recognition as User Input
Reactive Programming with the Observer Pattern
Managing Callbacks with a Registry
Applying the Speech Recognition Service to Components
Form Submission Validation and Verification
Summary
Chapter 9. Testing All the Things
Why Test?
Unit Testing
Defining Unit-Testable Code
Writing an Extension Method Unit Test
Component Testing
End-to-End Testing with Playwright
Automating Test Execution
Summary
Appendix. Learning Blazor App Projects
Web Client
Web API
Pwned Web API
Web Abstractions
Web Extensions
Web HTTP Extensions
Web Functions
Web Joke Services
Web Models
Web Twitter Components
Web Twitter Services
Index
About the Author
Colophon