Book Image

ASP.NET Core 5 for Beginners

By : Andreas Helland, Vincent Maverick Durano, Jeffrey Chilberto, Ed Price
Book Image

ASP.NET Core 5 for Beginners

By: Andreas Helland, Vincent Maverick Durano, Jeffrey Chilberto, Ed Price

Overview of this book

ASP.NET Core 5 for Beginners is a comprehensive introduction for those who are new to the framework. This condensed guide takes a practical and engaging approach to cover everything that you need to know to start using ASP.NET Core for building cloud-ready, modern web applications. The book starts with a brief introduction to the ASP.NET Core framework and highlights the new features in its latest release, ASP.NET Core 5. It then covers the improvements in cross-platform support, the view engines that will help you to understand web development, and the new frontend technologies available with Blazor for building interactive web UIs. As you advance, you’ll learn the fundamentals of the different frameworks and capabilities that ship with ASP.NET Core. You'll also get to grips with securing web apps with identity implementation, unit testing, and the latest in containers and cloud-native to deploy them to AWS and Microsoft Azure. Throughout the book, you’ll find clear and concise code samples that illustrate each concept along with the strategies and techniques that will help to develop scalable and robust web apps. By the end of this book, you’ll have learned how to leverage ASP.NET Core 5 to build and deploy dynamic websites and services in a variety of real-world scenarios.
Table of Contents (19 chapters)
1
Section 1 – Crawling
7
Section 2 – Walking
12
Section 3 – Running

What this book covers

Chapter 1, Introduction to ASP.NET Core 5, provides a short history lesson, going from .NET 1.0 via different paths to "one .NET to rule them all" with .NET Core, and how ASP .NET Core fits on top of that. There are a lot of terms that we'll cover and explain. There are also several tools that will be valuable for you as you move throughout this book, so we'll introduce a couple of these here.

Chapter 2, Cross-Platform Setup, explains how, given that .NET Core is not limited to running on Windows, developing on Linux and Mac is not an obstacle to building .NET apps. For Linux, the latest Windows 10 feature update provides an excellent developer companion with Windows Subsystem for Linux 2, which enables you to run natively on Linux and to debug from Windows. There are a couple of things that you'll need to be aware of when going cross-platform, and these details will be pointed out in this chapter.

Chapter 3, Dependency Injection, explains the dependency injection (DI) software design pattern and demonstrates how to use it to achieve inversion of control (IoC) between classes and their dependent classes. We'll cover the framework services, and we'll explain the service lifetimes and registration methods. Finally, you'll learn how to design services for DI.

Chapter 4, Razor View Engine, explains the concept whereby coding a page could become easier and more productive than ever before and you'll learn how Razor powers the different ASP.NET Core web frameworks to generate HTML markup (by using a unified markup syntax). To get a feel for the different web frameworks, you'll build a simple To-Do list application using Model View Controller (MVC) and Razor Pages to create a dynamic web app. In addition, you'll learn the pros and cons of each web framework.

Chapter 5, Getting Started with Blazor, explains how it's time to get familiar with a framework that enables you to build an interactive web UI with .NET. You can write with C# with JavaScript (and instead of JavaScript). You can share your server-side and client-side app logic that's written in .NET, and you can render your UI as HTML and CSS (which is great for mobile browsers). We'll kick things off by understanding the different Blazor hosting models for building powerful web applications and weigh their pros and cons. We'll then take a look at the high-level objective to achieve the goal of using cutting-edge technologies to build a real-world application. In this chapter, you'll be using Blazor to create a Tourist Spot application with real-time capabilities. You'll start building the backend side of the application using an ASP.NET Core Web API in concert with Entity Framework Core, and finally you'll set up real-time updates using SignalR.

Chapter 6, Exploring Blazor Web Frameworks, puts together the remaining pieces to complete the goal highlighted in Chapter 5 , Getting Started with Blazor. In this chapter, you'll be creating two different web applications using the different Blazor hosting models: Blazor Server and Blazor Web Assembly. This chapter is the heart of the book, where you experience what it's like to build different applications, using various technologies that connect to one another. The step-by-step code examples and visual illustrations make this chapter fun, exciting, and easy to follow.

Chapter 7, APIs and Data Access, takes you on a tour, as we explore how APIs and data access work together to achieve two main goals: serving and taking data. We'll take you on a whirlwind tour of Entity Framework, REST APIs, Database Management Systems (DBMSes), SQL, LINQ, and Postman. We'll start by understanding the different approaches when working with real databases in Entity Framework Core (EF Core). We will then look at how to use EF Core with an existing database, and we'll implement APIs that talk to a real database using EF Core's code-first approach. You will build an ASP.NET Core Web API application in concert with Entity Framework Core to perform basic data operations in a SQL Server database. You will also implement the most commonly used HTTP methods (verbs) for exposing some API endpoints and we'll perform some basic testing.

Chapter 8, Identity, aims to teach the basics of the concept of identity in an application, both from the frontend (how a user authenticates) and how the backend validates this identity. It will explain different methods, such as basic auth and claims-based auth, as well as introducing a modern identity suite (Azure AD). The major OAuth 2 and OpenID Connect flows will be explained to give an understanding of which to use in your applications.

Chapter 9, Containers, introduces the concept of breaking up monoliths and we'll provide a basic understanding of why everybody seems to be talking about containers today.

Chapter 10, Deploying to AWS and Azure, explains what is meant when we say that ASP.NET was born to be deployed to the cloud, and then we'll explore a few platforms, including Amazon Web Services (AWS) and Microsoft Azure (and we'll explain why we're focusing on these two platforms). Then, we'll delve in and show you how to get your project deployed (in a quick and basic way) on both AWS and Azure!

Chapter 11, Browser and Visual Studio Debugging, covers some of the great features available in modern browsers for detecting the cause of errors and how to troubleshoot issues. We'll also look at Visual Studio's support for debugging, and how the IDE can make you a better programmer.

Chapter 12, Integrating with CI/CD, goes into the tools and practices that programmers should be familiar with in the modern DevOps world.

Chapter 13, Cloud Native, explains how, given that a lot of job descriptions these days include the word cloud, and while not all code produced will be run in a public cloud, it is necessary to understand both what cloud native means, as well as which steps are involved in designing applications to take advantage of cloud capabilities. This could be cloud storage versus local disk, scaling up versus scaling out, and how some tasks previously handled by Ops are now the developer's responsibility. By the end of this chapter, you should understand why performing the lift and shift of an existing app is a lot different than starting out in the cloud.