Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Web Development with Blazor
Web Development with Blazor

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

eBook
€8.99 €41.99
Paperback
€52.99
Subscription
Free Trial
Renews at €18.99p/m

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 Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Web Development with Blazor

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.

Who is this book for?

This book is for .NET web developers and software developers who want to use their existing C# skills to build interactive SPA applications running either inside the web browser using Blazor WebAssembly, or on the server using Blazor Server. You’ll need intermediate-level web-development skills, basic knowledge of C#, and prior exposure to .NET web development before you get started; the book will guide you through the rest.

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, Length, Edition, Language, ISBN-13
Publication date : Mar 16, 2023
Length: 360 pages
Edition : 2nd
Language : English
ISBN-13 : 9781803231358
Vendor :
Microsoft
Languages :
Tools :

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 Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 135.97
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals
€44.99
Apps and Services with .NET 8
€37.99
Web Development with Blazor
€52.99
Total 135.97 Stars icon
Banner background image

Table of Contents

21 Chapters
Hello Blazor Chevron down icon Chevron up icon
Creating Your First Blazor App Chevron down icon Chevron up icon
Managing State – Part 1 Chevron down icon Chevron up icon
Understanding Basic Blazor Components Chevron down icon Chevron up icon
Creating Advanced Blazor Components Chevron down icon Chevron up icon
Building Forms with Validation Chevron down icon Chevron up icon
Creating an API Chevron down icon Chevron up icon
Authentication and Authorization Chevron down icon Chevron up icon
Sharing Code and Resources Chevron down icon Chevron up icon
JavaScript Interop Chevron down icon Chevron up icon
Managing State – Part 2 Chevron down icon Chevron up icon
Debugging the Code Chevron down icon Chevron up icon
Testing Chevron down icon Chevron up icon
Deploy to Production Chevron down icon Chevron up icon
Moving from, or Combining, an Existing Site Chevron down icon Chevron up icon
Going Deeper into WebAssembly Chevron down icon Chevron up icon
Examining Source Generators Chevron down icon Chevron up icon
Visiting .NET MAUI Chevron down icon Chevron up icon
Where to Go from Here Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
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 Half star icon 4.4
(19 Ratings)
5 star 68.4%
4 star 10.5%
3 star 10.5%
2 star 10.5%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Troy Martin Mar 22, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Background - I'm a self-taught programmer of 8+ years in various frameworks/engines/languages, mostly sticking with C# but fluent in many other notable languages. I suppose I'd be considered a life-long learner. I've recently been diving into web development to create a project I've been tossing around in my brain for a few months and have been consuming many books the last several months.This is the easiest 5 Star review I've given to a book for the last 6 months or so and has been added to my top 10 list of "Books You Need to own".With all that in mind, this is simply a must-have to ANYONE who is interested in web development and/or the Blazor framework. The book goes through everything you need to know to make your own web site from the very beginnings of a project and, throughout the book, construct a fully-functioning blog website ending in deployment and even tips on how to move from an existing site to Blazor.The first chapter explains Blazor in depth, including the differences between Server and Web Assembly, explaining how each one operates and even went so far as to creating a chart showing the differences in download size for single-page applications from large companies in comparison to a blazor sample setup.The second chapter gets into the creation of a new project. Everything is well documented and should leave no questions. There's SO much additional information here than what I am accustomed to when reading similar 'project creation' chapters from past books. It demonstrates the use of using the developer console through a browser to review file size transfer speeds, explaining EXACTLY what files are being sent and why. There's also CLI options Jimmy explains, which was much appreciated for me, being a Linux user. He then goes through each file created by a new project and covers exactly what each file does.From here on out, each chapter will introduce new concepts and you continue to build upon a blog web site using both Blazor Web Assembly and Server. Most notably are the chapters on Razor, two chapters on Blazor's component system, diving far into depth with all the features available to this, validation and forms (complete with admin panel), authentication, and so much more.Later chapters go way above and beyond what I would expect. It goes into advanced topics like browser storage, using a javascript interop to not only read js code in, but even go from .NET to JS or JS to .NET.Basically, I came into this book with the expectation I would use Blazor to build a blog page. What I WASN'T expecting was the amount of depth Jimmy goes into with exactly how everything works and why you would want to use it. Sprinkled through this read was things I didn't even know possible and it opens the door to a lot more experimentation / research.Buy this. You won't be disappointed.
Amazon Verified review Amazon
Imad Ayoub May 21, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
7 stars book for blazor developers. From zero to hero. Thanks a lot for the auditor.
Amazon Verified review Amazon
A. Zubarev May 01, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
In short, this is a book written by an expert for a future expert.After having read and practised the Blazor WebAssembly by Example by Toi B. Wright (which is a fine book in its own right) I wanted to continue on the learning path and decided to look into Web Development with Blazor.This book added a lot to my general knowledge where Blazor WebAssembly by Example left several common topics untouched, but excelled in covering creations of many typical applications and Blazor usage cases.It felt right away that the author of Web Development with Blazor is an advanced web developer, and as a bonus I liked the author's writing style, occasional humour and advice.Again, as oppose to how is the Blazor WebAssembly by Example is done, this book, instead of covering multiple projects, goes through only one - building a blog hosting engine. But covers it comprehensively and it resembles a monotonous typical developer's work on a large project, and is being done in an iterative manner with the end result having a complete product built.The other tidbit is a list of technical requirements at the beginning of each chapter which I find being nice to have to ensure one can complete it.The styling of the app is covered very well and I know that every project requires a lot of attention to.Besides, the JavaScript interop is thoroughly covered - this is especially valuable for those who are relatively new to the web development.Lastly, I can only think of one improvement: I wish the debugging part would come much earlier in the book.If you want to master Blazor - this is your book.
Amazon Verified review Amazon
Notchy Mar 16, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a well-written guide on Blazor Development. It assumes no prior knowledge and steadily goes from level to level with each new chapter, exploring the ins and outs of Blazor development.I recommend.
Amazon Verified review Amazon
Sarbjit Singh Hanjra Apr 28, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
"Web Development with Blazor" by Jimmy Engström published by Packt is an exceptional resource for anyone interested in learning how to develop web applications using Blazor, a cutting-edge technology that allows developers to build web apps using C# and .NET. This book covers all the essential topics, starting from the fundamentals of Blazor and gradually progressing towards more advanced concepts like Blazor components, validation, authentication, Managing State, testing, and deployment. The author's writing style is both clear and concise, providing an easy-to-follow guide throughout the book. Additionally, code examples are presented with accompanying screenshots, making it easier for readers to understand and implement the concepts. In summary, this book is highly recommended for developers who want to stay up-to-date with modern technologies like Blazor and .NET and build innovative web applications.
Amazon Verified review Amazon
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.