Book description
Discover blueprints that explore various components of Blazor, C#, and .NET to help you build web apps without learning JavaScript
Key Features
- Explore complete, easy-to-follow web projects using Blazor
- Build projects such as a weather app, expense tracker, and Kanban board with real-world applications
- Understand and work with Blazor WebAssembly effectively without spending too much time focusing on the theory
Book Description
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#.
What you will learn
- Discover the power of the C# language for both server-side and client-side web development
- Use the Blazor WebAssembly App project template to build your first Blazor WebAssembly application
- Use templated components and the Razor class library to build and share a modal dialog box
- Understand how to use JavaScript with Blazor WebAssembly
- Build a progressive web app (PWA) to enable native app-like performance and speed
- Understand dependency injection (DI) in .NET to build a shopping cart app
- Get to grips with .NET Web APIs by building a task manager app
Who this book is for
This book is for .NET web developers who are tired of constantly learning new JavaScript frameworks and wish to write web applications using Blazor WebAssembly, leveraging the power of .NET and C#. The book assumes beginner-level knowledge of the C# language, .NET framework, Microsoft Visual Studio, and web development concepts.
Table of contents
- Blazor WebAssembly by Example
- Foreword
- Contributors
- About the author
- About the reviewer
- Preface
- Chapter 1: Introduction to Blazor WebAssembly
-
Chapter 2: Building Your First Blazor WebAssembly Application
- Technical requirements
- Razor components
- Routing in Blazor WebAssembly
- Razor syntax
- Project overview
-
Creating the Demo Blazor WebAssembly project
- Creating the Demo project
- Running the Demo project
- Examining the Demo project's structure
- Examining the shared Razor components
- Examining the routable Razor components
- Using a component
- Adding a parameter to a component
- Using a parameter with an attribute
- Adding a route parameter
- Using partial classes to separate markup from code
- Creating a custom Blazor WebAssembly project template
- Summary
- Questions
- Further reading
- Chapter 3: Building a Modal Dialog Using Templated Components
- Chapter 4: Building a Local Storage Service Using JavaScript Interoperability (JS Interop)
-
Chapter 5: Building a Weather App as a Progressive Web App (PWA)
- Technical requirements
- Understanding PWAs
- Working with manifest files
- Working with service workers
- Using the CacheStorage API
- Using the Geolocation API
- Using the OpenWeather One Call API
- Project overview
-
Creating a PWA
- Getting started with the project
- Adding a JavaScript function
- Using the Geolocation API
- Adding a Forecast class
- Adding a DailyForecast component
- Using the OpenWeather One Call API
- Displaying the forecast
- Adding the logo
- Adding a manifest file
- Adding a simple service worker
- Testing the service worker
- Installing the PWA
- Uninstalling the PWA
- Summary
- Questions
- Further reading
-
Chapter 6: Building a Shopping Cart Using Application State
- Technical requirements
- Application state
- Understanding DI
- Project overview
-
Creating the shopping cart project
- Getting started with the project
- Adding the Product class
- Adding the Store page
- Demonstrating that application state is lost
- Creating the ICartService interface
- Creating the CartService class
- Registering CartService in the DI container
- Injecting CartService
- Adding the cart total to all of the pages
- Using the OnChange method
- Summary
- Questions
- Further reading
- Chapter 7: Building a Kanban Board Using Events
- Chapter 8: Building a Task Manager Using ASP.NET Web API
- Chapter 9: Building an Expense Tracker Using the EditForm Component
- Other Books You May Enjoy
Product information
- Title: Blazor WebAssembly by Example
- Author(s):
- Release date: July 2021
- Publisher(s): Packt Publishing
- ISBN: 9781800567511
You might also like
book
Blazor WebAssembly By Example - Second Edition
Build exciting web apps following step-by-step instructions and video examples. Purchase of the print or Kindle …
book
Blazor in Action
An example-driven guide to building reusable UI components and web frontends—all with Blazor, C#, and .NET. …
book
Test Driven Development: By Example
Quite simply, test-driven development is meant to eliminate fear in application development. While some fear is …
book
Bootstrap 4 By Example
Learn responsive web development with Bootstrap 4's front end framework About This Book Become an expert …