Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
$9.99 | ALL EBOOKS & VIDEOS
Over 7,000 tech titles at $9.99 each with AI-powered learning assistants on new releases
Web Development with Blazor, 2e - Second Edition
Web Development with Blazor, 2e - Second Edition

Web Development with Blazor, 2e: A practical guide to start building interactive UIs with C# 11 and .NET 7, Second Edition

By Jimmy Engström
$33.99 $9.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (1 Ratings)
Book Mar 2023 360 pages 2nd Edition
eBook
$33.99 $9.99
Print
$41.99
Subscription
$15.99 Monthly
eBook
$33.99 $9.99
Print
$41.99
Subscription
$15.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon AI Assistant (beta) to help accelerate your learning
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Table of content icon View table of contents Preview book icon Preview Book

Web Development with Blazor, 2e - Second Edition

Web Development with Blazor, Second Edition: A hands-on guide for .NET developers to build interactive UIs with C#

Welcome to Packt Early Access. We’re giving you an exclusive preview of this book before it goes on sale. It can take many months to write a book, but our authors have cutting-edge information to share with you today. Early Access gives you an insight into the latest developments by making chapter drafts available. The chapters may be a little rough around the edges right now, but our authors will update them over time.

You can dip in and out of this book or follow along from start to finish; Early Access is designed to be flexible. We hope you enjoy getting to know more about the process of writing a Packt book.

  1. Chapter 1: Hello Blazor
  2. Chapter 2: Creating Your First Blazor App
  3. Chapter 3: Managing State Part 1
  4. Chapter 4: Understanding Basic Blazor Components
  5. Chapter 5: Creating Advanced Blazor Components
  6. Chapter 6: Building Forms with validation...

Technical requirements

It is recommended that you have some knowledge of .NET before you start, as this book is aimed at .NET developers who want to utilize their skills to make interactive web applications. However, it’s more than possible that you will pick up a few .NET tricks along the way if you are new to the world of .NET.

Why Blazor?

Not that long ago, I got asked by a random person on Facebook if I was working with Blazor.

I said: Yes, yes I do.

He then continued with a long remark telling me that Blazor would never beat Angular, React, or Vue.

I see these kinds of remarks quite often, and it’s essential to understand that beating other SPA frameworks has never been the goal. This is not Highlander, and there can be more than one.

Learning web development has previously been pretty tough. Not only do we need to know ASP.NET for the server, but we also need to learn a SPA framework like React, Angular, or VUE.

But it doesn’t end there. We also need to learn NPM, Bower, and Parcel, as well as JavaScript or TypeScript.

We need to understand transpiling and build that into our development pipeline. This is, of course, just the tip of the iceberg; depending on technology, we need to explore other rabbit holes.

Blazor is an excellent choice for .NET developers to...

Preceding Blazor

You probably didn’t get this book to read about JavaScript, but it helps to remember that we are coming from a pre-Blazor time. I recall that time – the dark times. Many of the concepts used in Blazor are not that far from those used in many JavaScript frameworks, so I will start with a brief overview of our challenges.

As developers, we have many different platforms we can develop for, including desktop, mobile, games, the cloud (or server-side), AI, and even IoT. All these platforms have a lot of different languages to choose from, but there is, of course, one more platform: the apps that run inside the browser.

I have been a web developer for a long time, and I’ve seen code move from the server to run within the browser. It has changed the way we develop our apps. Frameworks such as Angular, React, Aurelia, and Vue have changed the web from reloading the whole page to updating small parts on the fly. This new on-the-fly update method...

Introducing WebAssembly

In this section, we will look at how WebAssembly works. One way of running Blazor is by using WebAssembly, but for now, let’s focus on what WebAssembly is.

WebAssembly is a binary instruction format that is compiled and, therefore, smaller. It is designed for native speeds, which means that when it comes to speed, it is closer to C++ than it is to JavaScript. When loading JavaScript, the JavaScript files (or inline) are downloaded, parsed, optimized, and JIT-compiled; most of those steps are not needed for WebAssembly.

WebAssembly has a very strict security model that protects users from buggy or malicious code. It runs within a sandbox and cannot escape that sandbox without going through the appropriate APIs. Suppose you want to communicate outside WebAssembly, for example, by changing the Document Object Model (DOM) or downloading a file from the web. In that case, you will need to do that with JavaScript interop (more on that later, and don...

Introducing .NET 7

The .NET team has been working hard on tightening everything up for us developers for years. They have been making everything simpler, smaller, cross-platform, and open source – not to mention easier to utilize your existing knowledge of .NET development.

.NET core was a step toward a more unified .NET. It allowed Microsoft to reenvision the whole .NET platform and build it in a completely new way.

There are three different types of .NET runtimes:

  • .NET Framework (full .NET)
  • .NET Core
  • Mono/Xamarin

Different runtimes had different capabilities and performances. This also meant that creating a .NET core app (for example) had different tooling and frameworks that needed to be installed.

.NET 5 is the start of our journey toward one single .NET. With this unified toolchain, the experience to create, run, and so on will be the same across all the different project types. .NET 5 is still modular in a similar way that we...

Introducing Blazor

Blazor is an open-source web UI SPA framework. That’s a lot of buzzwords in the same sentence, but simply put, it means that you can create interactive SPA web applications using HTML, CSS, and C# with full support for bindings, events, forms and validation, dependency injection, debugging, and much more. We will take a look at these in this book.

In 2017, Steve Sanderson (well-known for creating the Knockout JavaScript framework and who works for the ASP.NET team at Microsoft) was about to do a session called Web Apps can’t really do *that*, can they? at the developer conference NDC Oslo.

But Steve wanted to show a cool demo, so he thought, would it be possible to run C# in WebAssembly? He found an old inactive project on GitHub called Dot Net Anywhere, which was written in C and used tools (similar to what we just did) to compile the C code into WebAssembly.

He got a simple console app running inside the browser. This would have been...

Summary

In this chapter, you were provided with an overview of the different technologies you can use with Blazor, such as server-side (Blazor Server), client-side (WebAssembly), desktop, and mobile. This overview should have helped you decide what technology to choose for your next project.

We then discussed how Blazor was created and its underlying technologies, such as SignalR and WebAssembly. You also learned about the render tree and how the DOM gets updated to give you an understanding of how Blazor works under the hood.

In the upcoming chapters, I will walk you through various scenarios to equip you with the knowledge to handle everything from upgrading an old/existing site, and creating a new server-side site, to creating a new WebAssembly site.

We’ll get our hands dirty in the next chapter by configuring our development environment and creating and examining our first Blazor App.

Further reading

As a .NET developer, you might be interested in the Uno Platform (https://platform.uno/), which makes it possible to create a UI in XAML and deploy it to many different platforms, including WebAssembly.

If you want to see how the ZX Spectrum emulator is built, you can download the source code here: https://github.com/EngstromJimmy/ZXSpectrum.

Join our community on Discord 

Join our community’s Discord space for discussions with the author and other readers: 

https://packt.link/WebDevBlazor2e

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Create a production-ready Blazor application from start to finish
  • Learn Blazor fundamentals, gain actionable insights, and discover best practices
  • Find out how, when, and why to use Blazor Server and Blazor WebAssembly, as well as Blazor Hybrid

Description

Blazor is an essential tool if you want to build interactive web apps without JavaScript, but it has a learning curve. Updated with the latest code in .NET 7 and C# 11 and written by someone who adopted Blazor early, this book will help you overcome the challenges associated with being a beginner with Blazor and teach you the best coding practices. You’ll start by learning how to leverage the power of Blazor and exploring the full capabilities of both Blazor Server and Blazor WebAssembly. Then you'll move on to the practical part, centered around a sample project – a blog engine. You'll apply all your newfound knowledge about creating Blazor projects, the inner workings of Razor syntax, validating forms, and creating your own components. This new edition also looks at source generators, dives deeper into Blazor WebAssembly with ahead-of-time, and includes a dedicated new chapter demonstrating how to move components of an existing JavaScript (Angular, React) or MVC-based website to Blazor or combine the two. You’ll also see how to use Blazor (Hybrid) together with .NET MAUI to create cross-platform desktop and mobile applications. When you reach the end of this book, you'll have the confidence you need to create and deploy production-ready Blazor applications, and you'll have a big-picture view of the Blazor landscape.

What you will learn

Understand the different technologies that can be used with Blazor, such as Blazor Server, Blazor WebAssembly, and Blazor Hybrid Find out how to build simple and advanced Blazor components Explore the differences between Blazor Server and Blazor WebAssembly projects Discover how Minimal APIs work and build your own API Explore existing JavaScript libraries in Blazor and JavaScript interoperability Learn techniques to debug your Blazor Server and Blazor WebAssembly applications Test Blazor components using bUnit

Product Details

Country selected

Publication date : Mar 16, 2023
Length 360 pages
Edition : 2nd Edition
Language : English
ISBN-13 : 9781803241494
Vendor :
Microsoft
Category :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon AI Assistant (beta) to help accelerate your learning
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Mar 16, 2023
Length 360 pages
Edition : 2nd Edition
Language : English
ISBN-13 : 9781803241494
Vendor :
Microsoft
Category :

Table of Contents

22 Chapters
Preface Chevron down icon Chevron up icon
1. Hello Blazor Chevron down icon Chevron up icon
2. Creating Your First Blazor App Chevron down icon Chevron up icon
3. Managing State – Part 1 Chevron down icon Chevron up icon
4. Understanding Basic Blazor Components Chevron down icon Chevron up icon
5. Creating Advanced Blazor Components Chevron down icon Chevron up icon
6. Building Forms with Validation Chevron down icon Chevron up icon
7. Creating an API Chevron down icon Chevron up icon
8. Authentication and Authorization Chevron down icon Chevron up icon
9. Sharing Code and Resources Chevron down icon Chevron up icon
10. JavaScript Interop Chevron down icon Chevron up icon
11. Managing State – Part 2 Chevron down icon Chevron up icon
12. Debugging the Code Chevron down icon Chevron up icon
13. Testing Chevron down icon Chevron up icon
14. Deploy to Production Chevron down icon Chevron up icon
15. Moving from, or Combining, an Existing Site Chevron down icon Chevron up icon
16. Going Deeper into WebAssembly Chevron down icon Chevron up icon
17. Examining Source Generators Chevron down icon Chevron up icon
18. Visiting .NET MAUI Chevron down icon Chevron up icon
19. Where to Go from Here Chevron down icon Chevron up icon
20. Other Books You May Enjoy Chevron down icon Chevron up icon
21. Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(1 Ratings)
5 star 0%
4 star 100%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by


Anton Jan 23, 2024
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I like that the book quickly moves beyond simple cases and starts to build a set of projects that one can expect for a non-trivial project with long-term maintenance requirements. The biggest drawback of the book is that some of its discussions of key concepts are not applicable for .NET8, the current version.
Feefo Verified review Feefo image
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.