Build Single-Page Apps with WebAssembly and C#
David Pine
Blazor#
Azure#
Web_Apps#
HTTP#
ASP_NET_Core#
SignalR#
SPA#
PWA#
Microsoft#
GitHub#
JavaScript#
WebAssembly#
Single-Page#
از مهارتهای خود در زبان C# برای ساخت کامپوننتهای رابط کاربری (UI) و تجربههای سمت کلاینت با استفاده از .NET بهره بگیرید. با این راهنمای کاربردی، یاد میگیرید که چگونه با Blazor WebAssembly تجربههای مدرن وب توسعه دهید. Blazor که بر پایهی ASP.NET Core ساخته شده، آیندهی توسعهی برنامههای تکصفحهای (SPA) در اکوسیستم .NET را نمایندگی میکند.
نویسندهی کتاب، دیوید پاین (David Pine) که در مایکروسافت بر تولید محتوای مرتبط با .NET و Azure تمرکز دارد، توضیح میدهد که WebAssembly چگونه امکان اجرای زبانهای برنامهنویسی غیر از JavaScript را مستقیماً در مرورگر فراهم میکند. در این کتاب، با قابلیتهای بلادرنگ وب از طریق ASP.NET Core SignalR آشنا میشوید و استراتژیهایی برای تعامل دوطرفه با جاوااسکریپت (JavaScript Interop) را میآموزید. همچنین مباحثی همچون اتصال داده به کامپوننتها، ارتباط سلسلهمراتبی مبتنی بر رویدادها، مدیریت وضعیت در حافظه (in-memory state management) و استفاده از ذخیرهسازی محلی (Local Storage) نیز پوشش داده میشوند.
این کتاب به شما آموزش میدهد چگونه:
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 next-generation web experiences. Built on top of ASP.NET Core, Blazor represents the future of .NET single-page applications (SPA) 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. You'll learn strategies for bidirectional JavaScript interop. David covers component data binding, hierarchical event-driven communications, in-memory state management, and local storage.
This book shows you how to:
• Create a feature-rich Blazor app that looks beautiful
• Localize an enterprise-scale app as the sole developer using GitHub Actions and Azure Cognitive Services Translator service
• Create advanced validation scenarios for input-based components with forms
• Automatically deploy and host to Azure Static Web Apps, and rely on HTTP services
• Utilize geolocation service native to the browser, as well as native speech synthesis and recognition
• Author a custom modal verification mechanism for validating a user
• Determine the best approach for building reliable, architecturally sound websites
Table of Contents
Chapter 1. Blazing into Blazor
Chapter 2. Executing the App
Chapter 3. Componentizing
Chapter 4. Customizing the User Login Experience
Chapter 5. Localizing the App
Chapter 6. Exemplifying Real-Time Web Functionality
Chapter 7. Using Source Generators
Chapter 8. Accepting Form Input with Validation
Chapter 9. Testing All the Things
Welcome to Learning Blazor. You’re probably here because you’ve heard some cool things about Blazor and you want to try it out. So, what is it? Blazor is an open source web framework for building interactive client-side web UI components using C# (pronounced “see sharp”), HTML, and cascading style sheets (CSS). As a feature of ASP.NET Core, Blazor extends the .NET developer platform with tools and libraries for building web apps.
WebAssembly enables numerous non-JavaScript-based programming languages to run on the browser. Blazor takes full advantage of WebAssembly and allows C# developers to build UI components and client-side experiences with .NET. Blazor is a single-page application (SPA) framework, similar to Angular, React, VueJS, and Svelte, for example, but it’s based on C# instead of JavaScript.
Who Should Read This Book
This book is for .NET developers and web developers with a basic understanding of HTML, CSS, Document Object Model, and JavaScript, as well as some experience developing applications in .NET. This book is not for people who are complete beginners to programming. For instance, when I told my mom that I was writing a book, she asked what it was about and if she’d enjoy reading it. I said, “No.” She’s neither a .NET developer nor a web developer, so I don’t think she’d find much value in this book. If you’re a .NET developer or web developer, however, you’re in for a treat.
For .NET Developers: If you’re a .NET developer who is curious about web app development, this book will detail how you can harness your existing .NET skills and apply them to Blazor development. The web app platform is a major opportunity for .NET developers. All the popular JavaScript SPA frameworks, such as Angular, React, VueJS, and Svelte, have a true rival in Blazor. Blazor app development should be familiar to you as Blazor is based on .NET and C#. You can share libraries between client and server, making development truly enjoyable.
For Web Developers: If you’re a web developer who has worked with .NET before, this book extends two sets of learned programming skills. All of your .NET experience carries over, as does your knowledge of web fundamentals. If you’re a SPA developer, this book will open your eyes to a better set of tooling than you’re accustomed to. We also go over many new C# features. If you’re unfamiliar with C#, this book will provide an idiomatic view of C# and a strongly opinionated experience. Your JavaScript and developer experience of client-side routing and a deep understanding of HTTP,
microservice architecture, dependency injection, and component-based application mindset—all these things are directly applicable to Blazor development. Application development shouldn’t be so difficult, and I truly believe that Blazor makes it easier. With feature-rich data binding, strongly typed templating, component hierarchy eventing, logging, localization, authentication, support for PWA, and hosting, you have all the building blocks to orchestrate compelling web experiences.
As an experienced Blazor developer, I learned more about localization and testing from David Pine in 20 minutes of reading than I did in days of searching for similar insight online. Not only is Learning Blazor an educational piece, but it's also a great reference that I will return to when building future Blazor applications.
— Jeff Fritz, Live Streamer and Principle Program Manager, .NET Team, Microsoft
David Pine works in Developer Relations at Microsoft as a Senior Content Developer, focusing on .NET and Azure developer content. He is recognized as a Google Developer Expert in Web Technologies and is a Twilio Champion. Before joining Microsoft, David was a Microsoft MVP in Developer Technologies for several years. David thrives in the developer community, actively sharing knowledge through speaking engagements around the world. He advocates for open-source as a member of the .NET Foundation and has contributed to the .NET runtime and ASP.NET Core products, among many others. As a host of the revamped On .NET Live show, David invites you to immerse yourself and share experiences with the .NET community live, weekly.