Book description
Build modern, scalable, and cloud-ready single-page applications using ASP.NET Core, React, TypeScript, and Azure
Key Features
- Explore the full potential and latest features of .NET Core 3.0, TypeScript 3, and React
- Learn how to manage data, application design, and packaging, and secure your web apps
- Discover best practices for using React and TypeScript to build a scalable frontend that interacts with REST APIs
Book Description
Microsoft's ASP.NET Core is a robust and high-performing cross-platform web API framework, and Facebook's React uses declarative JavaScript to drive a rich, interactive user experience on the client-side web. Together, they can be used to build full stack apps with enhanced security and scalability at each layer.
This book will start by taking you through React and TypeScript components to build an intuitive single-page application. You'll understand how to design scalable REST APIs that can integrate with a React-based frontend. 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. The book shows how you can use TypeScript along with React to make the frontend robust and maintainable. You'll then cover important .NET Core features such as API controllers, attribute routing, and model binding to help you build a sturdy backend. Additionally, you'll explore API security with ASP.NET Core identity and authorization policies, and write reliable unit tests using both .NET Core and React before you deploy your app to the Azure cloud.
By the end of the book, you'll have gained all the knowledge you need to enhance your C# and JavaScript skills and build full stack, production-ready applications with ASP.NET Core and React.
What you will learn
- Build RESTful APIs with .NET Core using API controllers
- Create strongly typed, interactive, and function-based React components using Hooks
- Build forms efficiently using reusable React components
- Perform client-side state management with Redux and the React Context API
- Secure REST APIs with ASP.NET identity and authorization policies
- Run a range of automated tests on the frontend and backend
- Implement continuous integration (CI) and continuous delivery (CD) processes into Azure using Azure DevOps
Who this book is for
If you're a web developer looking to build solid full-stack web applications with .NET Core and React, this book is for you. Although this book does not assume any knowledge of React, you're expected to have a basic understanding of .NET Core.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- About Packt
- Contributors
- Preface
- Section 1: Getting Started
- Understanding the ASP.NET Core React Template
- Creating Decoupled React and ASP.NET Core Apps
- Section 2: Building a Frontend with React and TypeScript
- Getting Started with React and TypeScript
- Routing with React Router
- Working with Forms
- Managing State with Redux
- Section 3: Building an ASP.NET Core Backend
-
Interacting with the Database with Dapper
- Technical requirements
- Implementing the database
- Understanding what Dapper is and its benefits
- Installing and configuring Dapper
-
Reading data using Dapper
- Creating the repository class
- Creating a repository method to get questions
- Creating a repository method to get questions by a search
- Creating a repository method to get unanswered questions
- Creating a repository method to get a single question
- Creating a repository method to check whether a question exists
- Creating a repository method to get an answer
- Writing data using Dapper
- Managing migrations using DbUp
- Summary
- Questions
- Further reading
-
Creating REST API Endpoints
- Technical requirements
- Creating an API controller
-
Creating controller action methods
- Creating an action method for getting questions
- Extending the GetQuestions action method for searching
- Creating an action method for getting unanswered questions
- Creating an action method for getting a single question
- Creating an action method for posting a question
- Creating an action method for updating a question
- Creating an action method for deleting a question
- Creating an action method for posting an answer
- Adding model validation
- Removing unnecessary request fields
- Summary
- Questions
- Further reading
- Creating a Real-Time API with SignalR
- Improving Performance and Scalability
- Securing the Backend
-
Interacting with RESTful APIs
- Technical requirements
- Using fetch to interact with unauthenticated REST API endpoints
-
Interacting with Auth0 from the frontend
- Installing the Auth0 JavaScript client
- Recapping the sign-in and sign-out flow
- Creating the sign-in and sign-out routes
- Implementing a central authentication context
- Implementing the sign-in process
- Implementing the sign-out process
- Configuring Auth0 settings in our frontend
- Testing the sign-in and sign-out processes
- Controlling authenticated options
- Using fetch to interact with authenticated REST API endpoints
- Stopping a data state being set if the user navigates away from the page
- Summary
- Questions
- Further reading
- Section 4: Moving into Production
- Adding Automated Tests
- Configuring and Deploying to Azure
- Implementing CI and CD with Azure DevOps
-
Assessments
-
Answers
- Chapter 1 – Understanding the ASP.NET Core React Template
- Chapter 2 – Creating Decoupled React and ASP.NET Core Apps
- Chapter 3 – Getting Started with React and TypeScript
- Chapter 4 – Routing with React Router
- Chapter 5 – Working with Forms
- Chapter 6 – Managing State with Redux
- Chapter 7 – Interacting with the Database with Dapper
- Chapter 8 – Creating REST API Endpoints
- Chapter 9 – Creating a Real-Time API with SignalR
- Chapter 10 – Improving Performance and Scalability
- Chapter 11 – Securing the Backend
- Chapter 12 – Interacting with RESTful APIs
- Chapter 13 – Adding Automated Tests
- Chapter 14 – Configuring and Deploying to Azure
- Chapter 15 – Implementing CI and CD with Azure DevOps
-
Answers
- Other Books You May Enjoy
Product information
- Title: ASP.NET Core 3 and React
- Author(s):
- Release date: December 2019
- Publisher(s): Packt Publishing
- ISBN: 9781789950229
You might also like
book
ASP.NET Core 5 and React - Second Edition
Build fully functional, cloud-ready, and professional web applications using the latest features in the .NET 5 …
book
ASP.NET Core 5 for Beginners
Learn how to build web applications efficiently using ASP.NET Core 5 with the C# programming language …
book
Hands-On RESTful Web Services with ASP.NET Core 3
Get up to speed with the latest features of C# 8, ASP.NET Core 3 and .NET …
book
Microsoft Blazor: Building Web Applications in .NET
Build web applications in C# and Microsoft .NET that run in any modern browser. This second …