ASP.NET Core 5 and React
eBook - ePub

ASP.NET Core 5 and React

Full-stack web development using .NET 5, React 17, and TypeScript 4, 2nd Edition

Carl Rippon

Buch teilen
  1. 568 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

ASP.NET Core 5 and React

Full-stack web development using .NET 5, React 17, and TypeScript 4, 2nd Edition

Carl Rippon

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Build fully functional, cloud-ready, and professional web applications using the latest features in the.NET 5 framework and React.js with Microsoft Azure

Key Features

  • Explore the new features of.NET 5 with this updated edition of ASP.NET Core 5 and React
  • Discover strategies for adopting a full-stack development approach, clean architecture techniques, and development best practices
  • Learn how to manage data, design and package applications, and secure your web apps

Book Description

Microsoft's.NET framework is a robust server-side framework, now even more powerful thanks to the recent unification of the Microsoft ecosystem with the.NET 5 framework. This updated second edition addresses these changes in the.NET framework and the latest release of React.

The book starts by taking you through React and TypeScript components for building an intuitive single-page application and then shows you how to design scalable REST APIs that can integrate with a React-based frontend. Next, you'll get to grips with the latest features, popular patterns, and tools available in the React ecosystem, including function-based components, React Router, and Redux. As you progress through the chapters, you'll learn how to use React with TypeScript to make the frontend robust and maintainable and cover key ASP.NET 5 features such as API controllers, attribute routing, and model binding to build a sturdy backend. In addition to this, you'll explore API security with ASP.NET 5 identity and authorization policies and write reliable unit tests using both.NET and React, before deploying your app on Azure.

By the end of this book, you'll have gained the knowledge you need to enhance your C# and JavaScript skills and build full-stack, production-ready applications with ASP.NET 5 and React.

What you will learn

  • Build RESTful APIs with.NET 5 using API controllers
  • Secure REST APIs with identity and authorization policies
  • Create strongly typed, interactive, and function-based React components using Hooks
  • Understand how to style React components using Emotion.js
  • Perform client-side state management with Redux
  • Run a range of automated tests on the frontend and backend
  • Implement continuous integration and continuous delivery (CI/CD) processes in Azure using Azure DevOps

Who this book is for

If you're a web developer looking to get up to speed with full-stack web application development with.NET Core and React, this book is for you. Although the book does not assume any knowledge of React, a basic understanding of.NET Core will help you to get to grips with the concepts covered.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist ASP.NET Core 5 and React als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu ASP.NET Core 5 and React von Carl Rippon im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Web Services & APIs. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2021
ISBN
9781800207684

Section 1: Getting Started

This section provides a high-level introduction to ASP.NET Core and React and explains how to create projects that enable them to work well together. We will create the project for the app that we'll build throughout this book, which will allow users to submit questions and other users to submit answers to them—a Q&A app.
This section comprises the following chapters:
  • Chapter 1Understanding the ASP.NET 5 React Template
  • Chapter 2Creating Decoupled React and ASP.NET 5 Apps

Chapter 1: Understanding the ASP.NET 5 React Template

React was Facebook's answer to helping more people work on the Facebook code base and deliver features quicker. React worked so well for Facebook that they eventually open sourced it (https://github.com/facebook/react). Today, React is a mature library for building component-based frontends (client-side code that runs in the browser); it is extremely popular and has a massive community and ecosystem. At the time of writing, React is downloaded over 8.8 million times per week, which is 2 million more than the same time a year ago.
ASP.NET Core was first released in 2016 and is now a mature open source and cross-platform web application framework. It's an excellent choice for building backends (application code that runs on the server) that interact with databases such as SQL Server. It also works well in cloud platforms such as Microsoft Azure.
In this first chapter, we'll start by learning about the single-page application (SPA) architecture. Then, we'll create an ASP.NET Core and React app using the standard template in Visual Studio. We will use this to review and understand the critical parts of a React and ASP.NET Core app. Then, we'll learn where the entry points of both the ASP.NET Core and React apps are and how they integrate with each other. We'll also learn how Visual Studio runs both the frontend and backend together in development mode, as well as how it packages them up, ready for production. By the end of this chapter, we'll have gained fundamental knowledge so that we can start building an app that uses both of these awesome technologies, something we'll gradually build upon throughout this book.
In this chapter, we'll cover the following topics:
  • SPA architecture
  • Understanding the ASP.NET Core backend
  • Understanding the React frontend
Let's get started!

Technical requirements

We will need to use the following tools in this chapter:
  • Visual Studio 2019: This can be downloaded and installed from https://visualstudio.microsoft.com/vs/. Make sure that the following features are selected in the installer:
    a) ASP.NET and web development
    b) Azure development
    c) Node.js development
  • .NET 5.0: This can be downloaded from https://dotnet.microsoft.com/download/dotnet/5.0.
  • Node.js and npm: These can be downloaded from https://nodejs.org/.
All the code snippets in this chapter can be found online at https://github.com/PacktPublishing/ASP.NET-Core-5-and-React-Second-Edition.
Check out the following video to see the code in action: https://bit.ly/3riGWib.

SPA architecture

In this section, we will start to understand the single-page application (SPA) architecture.
A SPA is a web app that loads a single HTML page that is dynamically updated by JavaScript as the user interacts with the app. Imagine a simple sign-up form where a user can enter a name and an email address. When the user fills out and submits the form, a whole page refresh doesn't occur. Instead, some JavaScript in the browser handles the form submission with an HTTP POST request and then updates the page with the result of the request. Refer to the following diagram:
Figure 1.1 – Form in a SPA
Figure 1.1 – Form in a SPA
So, after the first HTTP request that returns the single HTML page, subsequent HTTP requests are only for data and not HTML markup. All the pages are rendered in the client's browser by JavaScript.
So, ho...

Inhaltsverzeichnis