Book description
Build exciting web apps following step-by-step instructions and video examples.
Purchase of the print or Kindle book includes a free eBook in PDF format.
Key Features
- Explore and build complete, easy-to-follow web projects using Blazor. Each project includes a video example too.
- Test your skills in building a weather app, an expense tracker, and a Kanban board with real-world applications.
- Develop a deeper understanding on how to work with Blazor WebAssembly without spending too much time focusing on the theory.
Book Description
Blazor WebAssembly helps developers build web applications without the need for JavaScript, plugins, or add-ons. With its continued growth in popularity, getting started with Blazor now can open doors to new career paths and exciting projects – and Blazor WebAssembly by Example will make your first steps easier. This is a project-based guide that will teach you how to build single-page web applications with Blazor, focusing heavily on the practical over the theoretical by providing detailed step-by-step instructions for each project. The author also includes a video for each project showing her following the step-by-step instructions, so readers can use them if they're unsure about any particular step.
In this updated edition, you'll start by building simple standalone web applications and gradually progress to developing more advanced hosted web applications with SQL Server backends. Each project will cover a different aspect of the Blazor WebAssembly ecosystem, such as Razor components, JavaScript interop, security, event handling, debugging on the client, application state, and dependency injection. The book’s projects get more challenging as you progress, but you don’t have to complete them in order, which makes this book a valuable resource for beginners as well as those who just want to dip into specific topics.
By the end of this book, you will have experience and lots of know-how on how to build 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
- Build your first Blazor WebAssembly application with the Blazor WebAssembly App project template
- Learn how to debug a Blazor WebAssembly app, and use ahead-of-time compilation before deploying it on Microsoft's cloud platform
- Use templated components and the Razor class library to build and share a modal dialog box
- Learn how to use JavaScript with Blazor WebAssembly
- Build a progressive web app (PWA) to enable native app-like performance and speed
- Secure a Blazor WebAssembly app using Azure Active Directory
- Gain experience with ASP.NET Web APIs by building a task manager app
Who this book is for
This book is for .NET web developers who want to leverage the power of .NET and C# to write single-page web applications using Blazor WebAssembly without using JavaScript frameworks. To get started with this book, you'll need at least beginner-level knowledge of the C# language, .NET framework, Microsoft Visual Studio, and web development concepts.
Table of contents
- Preface
- Introduction to Blazor WebAssembly
-
Building Your First Blazor WebAssembly Application
- Creating the Demo Blazor WebAssembly Project Technical Requirements
- Razor components
- Routing
- Razor syntax
- Hot Reload
-
Creating the Demo Blazor WebAssembly project
- Project overview
- Getting started with the project
- Running the Demo project
- Examining the Demo project’s structure
- Examining the shared Razor components
- Examining the routable Razor components
- Using a component
- Modifying 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
- Summary
- Questions
- Further reading
-
Debugging and Deploying a Blazor WebAssembly App
- Technical requirements
- Debugging a Blazor WebAssembly.app
- Debugging in Visual Studio
- Understanding logging
- Handling exceptions
- Using ahead-of-time (AOT) compilation
- Deploying a Blazor WebAssembly app to Microsoft Azure
-
Creating the “guess the number” project
- Project overview
- Getting started with the project
- Adding a Game component
- Adding the code
- Adding a style sheet
- Setting up and playing the game
- Adding logging
- Debugging in Visual Studio
- Updating the code
- Debugging in the browser
- Adding an ErrorBoundary component
- Deploying the application to Microsoft Azure
- Summary
- Questions
- Further reading
- Building a Modal Dialog Using Templated Components
- Building a Local Storage Service Using JavaScript Interoperability (JS Interop)
-
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
-
Creating a PWA
- Project overview
- Getting started with the project
- Add JavaScript to determine our location
- Invoke the JavaScript function
- Add an OpenWeather class
- Install Bootstrap
- Add a DailyForecast component
- Fetch the forecast
- Display the forecast
- Add the logo
- Add a manifest file
- Add a simple service worker
- Test the service worker
- Install the PWA
- Uninstall the PWA
- Summary
- Questions
- Further reading
-
Building a Shopping Cart Using Application State
- Technical requirements
- Introducing the application state
- Understanding DI
-
Creating the shopping cart project
- Project overview
- Creating the shopping cart project
- Installing Bootstrap
- Adding a Store component
- Adding a Product class
- Finishing the Store component
- Demonstrating that the application state has been lost
- Creating the the ICartService interface
- Creating the CartService class
- Registering CartService in the DI container
- Injecting CartService into the Store component
- Adding the cart total to all the pages
- Using the OnChange method
- Summary
- Questions
- Further reading
- Building a Kanban Board Using Events
- Uploading and Reading an Excel File
-
Using Azure Active Directory to Secure a Blazor WebAssembly Application
- Technical requirements
- Understanding the difference between authentication and authorization
- Working with authentication
- Controlling the user interface using authorization
-
Creating the claims viewer project
- Project overview
- Create the claims viewer project
- Add the application to Azure AD
- Add a user and a group to Azure AD
- Add the required NuGet packages
- Enable authentication
- Add an Authentication component
- Add a LoginDisplay component
- Add a Secure component
- Add a WhoAmI component
- View the JSON Web Token (JWT)
- Add an authentication policy
- Summary
- Questions
- Further reading
- Building a Task Manager Using ASP.NET Web API
- Building an Expense Tracker Using the EditForm Component
- Other Books You May Enjoy
- Index
Product information
- Title: Blazor WebAssembly By Example - Second Edition
- Author(s):
- Release date: February 2023
- Publisher(s): Packt Publishing
- ISBN: 9781803241852
You might also like
book
Blazor WebAssembly by Example
Discover blueprints that explore various components of Blazor, C#, and .NET to help you build web …
book
Microservices in .NET, Second Edition
In Microservices in .NET, Second Edition you will learn how to: Build scalable microservices that are …
book
ASP.NET Core in Action, Second Edition
Fully updated to ASP.NET 5.0, ASP.NET Core in Action, Second Edition is a hands-on primer to …
book
React: Up & Running, 2nd Edition
Hit the ground running with React, the open source technology from Facebook for building rich web …