ASP.NET Core 5 and Angular
eBook - ePub

ASP.NET Core 5 and Angular

Full-stack web development with .NET 5 and Angular 11, 4th Edition

  1. 746 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

ASP.NET Core 5 and Angular

Full-stack web development with .NET 5 and Angular 11, 4th Edition

About this book

Build robust modern web applications using.NET 5, Entity Framework Core, and Angular 11

Key Features

  • Updated with the latest features and additions in ASP.NET Core 5 and Angular 11
  • Design, build, and deploy a Single Page Application or Progressive Web App
  • Adopt a full stack approach to handle data management, Web APIs, application design, testing, SEO, security, and deployment

Book Description

Learning full-stack development calls for knowledge of both front-end and back-end web development. ASP.NET Core 5 and Angular, Fourth Edition will enhance your ability to create, debug, and deploy efficient web applications using ASP.NET Core and Angular. This revised edition includes coverage of the Angular routing module, expanded discussion on the Angular CLI, and detailed instructions for deploying apps on Azure, as well as both Windows and Linux.

Taking care to explain and challenge design choices made throughout the text, Valerio teaches you how to build a data model with Entity Framework Core, alongside utilizing the Entity Core Fluent API and EntityTypeConfiguration class. You'll learn how to fetch and display data and handle user input with Angular reactive forms and front-end and back-end validators for maximum effect.

Later, you will perform advanced debugging and explore the unit testing features provided by xUnit.net (.NET 5) and Jasmine, as well as Karma for Angular. After adding authentication and authorization to your apps, you will explore progressive web applications (PWAs), learning about their technical requirements, testing, and converting SWAs to PWAs.

By the end of this book, you will understand how to tie together the front end and back end to build and deploy secure and robust web applications.

What you will learn

  • Implement a web API interface with ASP.NET Core and consume it with Angular using RxJS observables
  • Set up an SQL database server using a local instance or a cloud data store
  • Perform C# and TypeScript debugging using Visual Studio 2019
  • Create TDD and BDD unit tests using xUnit, Jasmine, and Karma
  • Perform DBMS structured logging using third-party providers such as SeriLog
  • Deploy web apps to Windows and Linux web servers, or Azure App Service, using IIS, Kestrel, and nginx

Who this book is for

This book is for experienced ASP.NET developers who already possess some familiarity with ASP.NET Core and Angular and are looking to learn how to use them effectively together.

The fully documented code samples (also available on GitHub) and the step-by-step implementation tutorials make this book easy to follow.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access ASP.NET Core 5 and Angular by Valerio De Sanctis in PDF and/or ePUB format, as well as other popular books in Computer Science & Microsoft Programming. We have over one million books available in our catalogue for you to explore.

Information

6

Forms and Data Validation

In this chapter, we'll mostly deal with forms, data input, and validation techniques. As we already know, HTML forms are one of the most important and delicate aspects of any business application. Nowadays, forms are used to fulfill almost any task involving user-submitted data, such as registering or logging in to a website, issuing a payment, reserving a hotel room, ordering a product, performing and retrieving search results, and more.
If we were asked to define a form from a developer's perspective, we would come out with the statement that a form is a UI-based interface that allows authorized users to enter data that will be sent to a server for processing. The moment we accept this definition, two additional considerations should come to mind:
  • Each form should provide a data entry experience good enough to efficiently guide our users through the expected workflow; otherwise, they won't be able to use it properly.
  • Each form, as long as it brings potentially insecure data to the server, could have a major security impact in terms of data integrity, data security, and system security, unless the developer possesses the required know-how to adopt and implement the appropriate countermeasures.
These two considerations provide a good summary of what we'll do in this chapter: we'll do our best to guide our users into submitting data in the most appropriate way, and we'll also learn how to check these input values properly to prevent, avoid, and/or minimize a wide spectrum of integrity and security threats. It's also important to understand that these two considerations are frequently intertwined with each other; hence, we'll often deal with them at the same time.
In this chapter, we'll cover the following topics:
  • Angular forms, where we'll deal with Template-Driven Forms as well as Reactive Forms, all while understanding the pros and cons of both approaches and looking at which is the most suitable to use in various common scenarios.
  • Data validation, where we'll learn how to double-check our users' input data in the front-end and also from the back-end, as well as the various techniques to give visual feedback when they send incorrect or invalid values.
  • Form builder, where we'll implement another Reactive Form using some factory methods instead of manually instantiating the various form model elements.
At the end of each task, we'll also take some time to verify the result of our work using our web browser.

Technical requirements

In this chapter, we're going to need all the technical requirements that we mentioned in the previous chapters, with no additional resources, libraries, or packages.
The code files for this chapter can be found at: https://github.com/PacktPublishing/ASP.NET-Core-5-and-Angular/tree/main/Chapter_06

Exploring Angular forms

If we take a look at our current .NET Core with Angular projects, we will see how none of them allow our users to interact with the data:
  • For the HealthCheck app, this is expected since there's simply no data to deal with: this is a monitor app that doesn't store anything and requires no input from the user.
  • The WorldCities app, howeve...

Table of contents

  1. Preface
  2. Getting Ready
  3. Looking Around
  4. Front-End and Back-End Interactions
  5. Data Model with Entity Framework Core
  6. Fetching and Displaying Data
  7. Forms and Data Validation
  8. Code Tweaks and Data Services
  9. Back-End and Front-End Debugging
  10. ASP.NET Core and Angular Unit Testing
  11. Authentication and Authorization
  12. Progressive Web Apps
  13. Windows, Linux, and Azure Deployment
  14. Other Books You May Enjoy
  15. Index