Blazor
$4.99
Minimum price
$9.99
Suggested price

Blazor

Blazing past the competition

About the Book

Blazor lets you build interactive web UIs with the use of C# instead of JavaScript. This includes typical concepts like reusable components, data-binding, routing and more. Components are implemented using the familiar cornerstones C#, HTML, and CSS. Both client and server code is written in C# allowing code and libraries to be shared seamlessly.

This book offers an introduction to Blazor and the history of web development along with step-by-step guides on common use cases. The final chapters gives pointers to good references and the future of Blazor.

About the Author

Johan Litsfeldt
Johan Litsfeldt

I am a software engineer with 7+ years of working experience in IT and a M.Sc. in Computer Science from KTH (Royal Institute of Technology) in Sweden.

Table of Contents

1 Introduction 7 1.1 Painpoints .................. 7 1.2 History .................... 10 1.3 What is Blazor? ............... 11 1.4 Why Blazor? ................. 12 2 Background 15 2.1 The.NETFramework............ 15 2.2 WebAssembly ................ 18 2.3 SignalR .................... 19 2.4 TheVirtualDOM .............. 20 3 Blazor variants 23 3.1 Choosing your flavour . . . . . . . . . . . . 23 3.1.1 Blazor WebAssembly . . . . . . . . 24 3.1.2 Blazor Server............. 25 3.2 Setting up your environment . . . . . . . . 27 3.3 Blazor WebAssembly ............ 27 3.3.1 Your first Blazor WebAssembly App 28 3.3.2 Project Structure . . . . . . . . . . 29 3.4 Blazor Server................. 31 3.4.1 Your first Blazor Server App . . . . 31 3.4.2 Project Structure .......... 32 4 Blazor in-depth 35 4.1 Components ................. 35 4.2 Code-behind ................. 36 4.3 Passing data between components . . . . . 37 4.3.1 Parameters.............. 37 4.3.2 Routing parameters . . . . . . . . . 38 4.3.3 Cascading parameters . . . . . . . . 40 4.3.4 Event callbacks ........... 42 4.3.5 The ref attribute........... 43 4.4 Data binding ................. 46 4.4.1 One-way data binding . . . . . . . . 48 4.4.2 Two-way data binding . . . . . . . . 49 4.5 TemplatedComponents........... 52 4.5.1 Template parameters . . . . . . . . 52 4.5.2 Template context parameters . . . . 55 4.6 Lifecycle & rendering triggers . . . . . . . . 56 4.6.1 Component Lifecycle Events . . . . 56 4.7 Forms and Validations............ 60 4.7.1 Built-in form components . . . . . 66 4.7.2 Fluent validation........... 67 4.8 Dependency Injection............ 68 4.8.1 Blazor WebAssembly DI . . . . . . 70 4.8.2 Blazor Server DI........... 72 4.9 Authentication & Authorization . . . . . . 74 4.9.1 Blazor Server Auth ......... 74 4.9.2 AuthenticationStateProvider service 78 4.9.3 Blazor WebAssemby Auth . . . . . 79 4.10 Statemanagement .............. 83 4.10.1 Server-side storage. . . . . . . . . . 83 4.10.2 URL ................. 84 4.10.3 Browser storage ........... 84 4.10.4 State container service . . . . . . . 86 4.11 Component Virtualization . . . . . . . . . 88 4.12 CSSIsolation................. 91 4.13 Debugging .................. 93 4.13.1 IDE debugging ........... 93 4.13.2 Logging................ 95 4.14 JavaScript Interop .............. 97 4.14.1 Calling JavaScript from .NET . . . 97 4.14.2 Calling .NET from JavaScript . . . 101 4.14.3 npm packages in Blazor . . . . . . . 105 5 Blazor in the real world 107 5.1 In the Cloud ................. 107 5.1.1 Publishing to Azure . . . . . . . . . 108 5.1.2 AzureADB2C............ 108 5.1.3 Serverless architectures . . . . . . . 110 5.2 Mobile&Desktop.............. 111 5.2.1 Progressive Web Applications . . . 111 5.3 Blazor Libraries ............... 113 5.4 What’s Next?................. 114

Causes Supported

Tree-Nation

You reforest the world
https://tree-nation.com

Tree-Nation is the largest reforestation platform enabling citizens and companies to plant trees around the world.

Tree-Nation’s mission is to reforest the world. The organisation offers people the possibility to select from over 300 different tree species which can be planted in 50 different reforestation projects located in 6 different continents. In every project, the species are carefully selected according to the specific benefits they bring for the environment and to the local population. Each tree planted on the Tree-Nation platform is assigned its own unique URL, which means the species, the location, the plantation project information and the CO2 compensation values can be tracked throughout the lifetime of the tree. Since its inception in 2006, more than 130,000 users and more than 2,200 companies have planted 5 million trees using its platform.

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$10,628,331writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub