0%

Learn modern web user interface (UI) development with server-side Blazor and Blazor WebAssembly

Key Features

  • Get up to speed with Blazor fundamentals, actionable insights, and best practices
  • Learn how to create and deploy a production-ready Blazor application
  • Find out how, when, and why to use server-side Blazor and Blazor WebAssembly

Book Description

Until now, creating interactive web pages meant involving JavaScript. But with Blazor, Microsoft's new way to create .NET web applications, developers can easily build interactive and rich web applications using C#. Web Development with Blazor will guide you through the most common challenges in getting started with Blazor.

You'll start by learning how to leverage the power of Blazor and learn what you can do with both Blazor Server and Blazor WebAssembly. By showing you how all the elements work together practically, the book will help you solve some of the common roadblocks that developers face. As you advance, you'll learn how to create Blazor Server and Blazor WebAssembly projects, how Razor syntax works, and how to validate forms and create your own components. Later, the book introduces you to key concepts involved in web development with Blazor, which you will be able to put into practice straight away.

By the end of this Blazor book, you'll have gained the confidence you need to create and deploy production-ready Blazor applications.

What you will learn

  • Understand the different technologies that can be used with Blazor, such as Blazor Server and Blazor WebAssembly
  • Find out how to build simple and advanced Blazor components
  • Explore the differences between Blazor Server and Blazor WebAssembly projects
  • Discover how Entity Framework works and build a simple API
  • Get up to speed with components and find out how to create basic and advanced components
  • Explore existing JavaScript libraries in Blazor
  • Use techniques to debug your Blazor Server and Blazor WebAssembly applications
  • Test Blazor components using bUnit

Who this book is for

This web development book is for web developers and software developers who want to explore Blazor for building dynamic web UIs. This book assumes beginner-level knowledge of C# programming and intermediate-level web development skills.

Table of Contents

  1. Web Development with Blazor
  2. Foreword
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  7. Section 1:The Basics
  8. Chapter 1: Hello Blazor
    1. Technical requirements
    2. Preceding Blazor
    3. Introducing WebAssembly
    4. Introducing .NET 5
    5. Introducing Blazor
    6. Blazor Server
    7. Blazor WebAssembly
    8. Blazor WebAssembly versus Blazor Server
    9. WebWindow
    10. Blazor Mobile Bindings
    11. Summary
    12. Further reading
  9. Chapter 2: Creating Your First Blazor App
    1. Technical requirements
    2. Setting up your development environment
    3. Windows
    4. macOS
    5. Linux (or macOS or Windows)
    6. Creating our first Blazor application
    7. Creating a Blazor Server application
    8. Creating a WebAssembly application
    9. Using the command line
    10. Creating a Blazor Server project using the command line
    11. Figuring out the project structure
    12. Program.cs
    13. Startup
    14. Index/_host
    15. App
    16. MainLayout
    17. Bootstrap
    18. Summary
  10. Section 2:Building an Application with Blazor
  11. Chapter 3: Introducing Entity Framework Core
    1. Technical requirements
    2. Creating a data project
    3. Creating a new project
    4. Adding NuGet packages
    5. Creating data classes
    6. Creating the Database Context
    7. Creating a migration
    8. Creating an interface
    9. Implementing the interface
    10. Adding the DbContext to Blazor
    11. Summary
  12. Chapter 4: Understanding Basic Blazor Components
    1. Technical requirements
    2. Exploring components
    3. counter
    4. FetchData
    5. Learning Razor syntax
    6. Razor code blocks
    7. Implicit Razor expressions
    8. Explicit Razor expressions
    9. Expression encoding
    10. Directives
    11. Understanding dependency injection
    12. Figuring out where to put the code
    13. Lifecycle events
    14. Parameters
    15. Cascading parameters
    16. Writing our first component
    17. Summary
  13. Chapter 5: Creating Advanced Blazor Components
    1. Technical requirements
    2. Exploring binding
    3. One-way binding
    4. Two-way binding
    5. Adding Actions and EventCallback
    6. Using RenderFragment
    7. ChildContent
    8. Default value
    9. Building an alert component
    10. Exploring the new built-in component
    11. Setting the focus of the UI
    12. Influencing HTML head
    13. Component virtualization
    14. Summary
  14. Chapter 6: Building Forms with Validation
    1. Technical requirements
    2. Exploring form elements
    3. EditForm
    4. InputBase<>
    5. InputCheckbox
    6. InputDate<TValue>
    7. InputNumber<TValue>
    8. InputSelect<TValue>
    9. InputText
    10. InputTextArea
    11. InputRadio
    12. InputRadioGroup
    13. Adding validation
    14. ValidationMessage
    15. ValidationSummary
    16. Custom validation class attributes
    17. Building an admin interface
    18. Listing and editing categories
    19. Listing and editing tags
    20. Listing and editing blog posts
    21. Summary
  15. Chapter 7: Creating an API
    1. Technical requirements
    2. Creating the service
    3. Adding database access
    4. Adding the API controller
    5. Creating the client
    6. Summary
  16. Chapter 8: Authentication and Authorization
    1. Technical requirements
    2. Implementing authentication
    3. Adding tables to the database
    4. Configuring the Blazor Server project
    5. Configuring the Blazor WebAssembly project
    6. Adding authorization
    7. Adding roles from the server
    8. Adding roles to the client
    9. Adding a role to the database
    10. Summary
  17. Chapter 9: Sharing Code and Resources
    1. Technical requirements
    2. Cleaning up the project
    3. Setting up the API
    4. Moving the components
    5. Cleaning up the shared files
    6. Adding the API
    7. Adding static files
    8. CSS versus LESS versus SASS
    9. Preparing CSS/SASS
    10. Adding CSS to MyBlogServerSide
    11. Adding CSS to MyBlogWebAssembly.Client
    12. Making the admin interface more useable
    13. Making the menu more useful
    14. Making the blog look like a blog
    15. Sharing problems
    16. CSS isolation
    17. Summary
  18. Chapter 10: JavaScript Interop
    1. Technical requirements
    2. Why do we need JavaScript?
    3. .NET to JavaScript
    4. Global JavaScript (the old way)
    5. JavaScript Isolation
    6. JavaScript to .NET
    7. Static .NET method call
    8. Instance method call
    9. Implementing an existing JavaScript library
    10. Summary
  19. Chapter 11: Managing State
    1. Technical requirements
    2. Storing data on the server side
    3. Storing data in the URL
    4. Route constraints
    5. Using a query string
    6. Scenarios that are not that common
    7. Implementing browser storage
    8. Creating an interface
    9. Implementing Blazor Server
    10. Implementing WebAssembly
    11. Implementing the shared
    12. Using an in-memory state container service
    13. Implementing real-time updates on Blazor Server
    14. Implementing real-time updates on Blazor WebAssembly
    15. Summary
  20. Section 3:Debug, Test, and Deploy
  21. Chapter 12: Debugging
    1. Technical requirements
    2. Making things break
    3. Debugging Blazor Server
    4. Debugging Blazor WebAssembly
    5. Debugging Blazor WebAssembly in the web browser
    6. Hot reload (almost the real thing)
    7. Summary
  22. Chapter 13: Testing
    1. Technical requirements
    2. What is bUnit?
    3. Setting up a test project
    4. Mocking the API
    5. Writing tests
    6. Authentication
    7. Testing JavaScript
    8. Summary
  23. Chapter 14: Deploy to Production
    1. Technical requirements
    2. Continuous delivery options
    3. Deploying the database
    4. Hosting options
    5. Hosting Blazor Server
    6. Hosting Blazor WebAssembly
    7. Hosting on IIS
    8. Summary
  24. Chapter 15: Where to Go from Here
    1. Technical requirements
    2. Learnings from running Blazor in production
    3. Solving memory problems
    4. Solving concurrency problems
    5. Solving errors
    6. Old browsers
    7. Next steps
    8. The community
    9. The components
    10. Summary
    11. Why subscribe?
  25. Other Books You May Enjoy
    1. Packt is searching for authors like you
3.15.225.173