Author(s): Jason De Oliveira, Michel Bruchet, Et al
Edition: Second Edition
Publisher: Packt Publishing
Year: 27 Dec 2019
Language: English
Pages: 558
Cover......Page 1
Title Page......Page 2
Copyright and Credits......Page 3
Dedication......Page 4
About Packt......Page 5
Contributors......Page 6
Table of Contents......Page 9
Preface......Page 15
Section 1: Introduction and Environment Setup......Page 26
Chapter 1: What Is ASP.NET Core 3?......Page 27
The history of ASP.NET ......Page 28
ASP.NET Core 3 features......Page 30
What is new specifically to ASP.NET Core 3?......Page 31
Cross-platform support......Page 33
Microservice architecture......Page 35
Performance and scalability......Page 36
Technology restrictions......Page 37
When to choose ASP.NET Core 3......Page 38
Summary......Page 39
Chapter 2: Setting Up the Environment......Page 40
Visual Studio 2019 as a development environment......Page 41
How to install Visual Studio 2019 Community Edition......Page 42
First steps with Visual Studio 2019......Page 46
Creating your first ASP.NET Core 3 application in Visual Studio 2019......Page 50
Creating your first ASP.NET Core 3 application via the command line......Page 55
Basic debugging with Visual Studio 2019......Page 57
Breakpoints......Page 59
Call stack......Page 60
Visual Studio Code as a development environment......Page 61
How to install Visual Studio Code on Linux......Page 63
Creating your first ASP.NET Core 3 application in Visual Studio Code......Page 66
Creating your first ASP.NET Core 3 application in Linux......Page 68
Introduction to the C# Interactive and LINQPad tools......Page 70
Summary......Page 72
Chapter 3: Continuous Integration Pipeline in Azure DevOps......Page 73
CI, CD, and build and release pipelines......Page 74
Using Azure DevOps for CI and CD......Page 75
Creating a free Azure DevOps subscription and your first Azure DevOps project......Page 76
Organizing your work via work items......Page 78
Understanding the scrum process......Page 80
Using Git as a VCS......Page 85
Using feature branches......Page 91
Merging changes and resolving conflicts......Page 93
Creating an Azure DevOps build pipeline......Page 97
Creating an Azure DevOps release pipeline......Page 101
Summary......Page 102
Section 2: A Practical Demonstration of ASP.NET Core 3......Page 103
Chapter 4: Basic Concepts of ASP.NET Core 3 via a Custom Application: Part 1......Page 104
Preview of the Tic-Tac-Toe demo application......Page 105
Building the Tic-Tac-Toe game......Page 106
Conceiving and implementing your first Tic-Tac-Toe feature......Page 107
Targeting different .NET Core versions in the .csproj files of your projects......Page 111
Using the Microsoft.AspNetCore.App metapackage......Page 112
Introduction to the default ASP.NET Core 3 classes......Page 113
Working with the Program class......Page 114
Working with .NET Generic Host instead of WebHostBuilder......Page 116
Working with the Startup class......Page 117
Preparing the basic project structure......Page 119
Creating the Tic-Tac-Toe home page......Page 121
Giving your web pages a more modern look by using NPM and layout pages......Page 126
Updating the layout page......Page 129
Creating the Tic-Tac-Toe user registration page......Page 133
Using DI to encourage loose coupling......Page 136
Creating the user service......Page 137
Working with middleware......Page 141
Creating the communication middleware......Page 144
Working with static files......Page 146
Using routing, URL redirection, and URL rewriting......Page 148
Endpoint routing for ASP.NET Core 3......Page 151
Adding error handling to the Tic-Tac-Toe application......Page 152
Summary......Page 158
Chapter 5: Basic Concepts of ASP.NET Core 3 via a Custom Application: Part 2......Page 159
Client-side development using JavaScript......Page 160
Preliminary email confirmation functionality......Page 161
Email confirmation by our user......Page 163
Using XMLHttpRequest......Page 167
Optimizing your web applications and using bundling and minification......Page 172
Bundling and minification in action......Page 173
Working with WebSockets for real-time communication scenarios......Page 177
WebSockets in action......Page 178
Taking advantage of session and user cache management......Page 182
In-memory session providers......Page 183
Distributed session providers......Page 187
Globalization and localization concepts......Page 188
Using the view localizer ......Page 195
Localizing Data Annotations......Page 198
Adding an email service......Page 202
Configuring the email service......Page 204
Method injection......Page 208
Summary......Page 215
Chapter 6: Introducing Razor Components and SignalR......Page 216
Client-side development using C# Razor components......Page 217
What is SignalR......Page 221
SignalR with server-side Blazor or Razor components......Page 222
Using logging and telemetry for monitoring and supervision purposes......Page 223
Building once and running on multiple environments......Page 235
Summary......Page 241
Chapter 7: Creating ASP.NET Core MVC Applications......Page 242
Understanding the Model View Controller pattern......Page 243
Models......Page 244
Unit tests......Page 245
Creating dedicated layouts for multiple devices......Page 246
The layout page in more detail......Page 247
Optimizing for mobile devices......Page 250
Understanding ASP.NET Core state management......Page 255
Cookies......Page 256
Query string usage......Page 257
Session state......Page 258
Using view pages, partial views, View Components, and Tag Helpers......Page 259
Using view pages......Page 260
Using partial views......Page 267
Using View Components......Page 268
Using Tag Helpers......Page 274
Dividing a web application into multiple areas......Page 280
Using view engines......Page 284
Providing better quality by creating unit tests and integration tests......Page 291
Adding unit tests......Page 296
Adding integration tests......Page 300
Layering ASP.NET Core 3 applications......Page 302
Determining the required layers......Page 303
Determining rules for interactions between layers......Page 304
Summary......Page 305
Chapter 8: Creating Web API Applications......Page 307
Applying web API concepts and best practices......Page 308
Building RPC-style web APIs......Page 310
Building REST-style web APIs......Page 326
Building HATEOAS-style web APIs......Page 335
Securing your web API......Page 337
ASP.NET Core web API help pages with Swagger/OpenAPI......Page 338
Summary......Page 342
Section 3: The ASP.NET Core 3 Supporting Ecosystem......Page 343
Chapter 9: Accessing Data Using Entity Framework Core 3......Page 344
Establishing a connection......Page 347
Defining primary keys and foreign keys via Data Annotations......Page 350
Using Entity Framework Core 3 migrations......Page 354
Creating, reading, updating, and deleting data......Page 358
Primary key......Page 360
Foreign key......Page 361
One-to-many relationships......Page 362
Many-to-many relationships......Page 363
Querying for one item......Page 364
Querying for filtered items......Page 365
Using transactions......Page 366
Summary......Page 367
Chapter 10: Securing ASP.NET Core 3 Applications......Page 368
Implementing authentication......Page 369
Adding basic user form authentication......Page 383
Adding external provider authentication......Page 391
Working with two-factor authentication......Page 394
Two-factor authentication - step by step......Page 395
Adding forgotten password and password reset mechanisms......Page 404
Implementing authorization......Page 413
Summary......Page 422
Chapter 11: Securing ASP.NET Applications - Vulnerabilities......Page 423
Cross-Site Scripting (XSS)......Page 424
Preventing XSS......Page 425
Preventing cookie stealing......Page 426
Preventing eavesdropping and message replay......Page 427
Open redirects example......Page 428
Preventing SQL injection......Page 429
Using object-relational mappers (ORMs)......Page 430
XSRF/CSRF example......Page 431
Domain referrers......Page 432
User-generated tokens......Page 433
Over-posting......Page 434
Preventing over-posting......Page 435
Preventing clickjacking......Page 436
Proper error reporting and stack trace......Page 438
Preventing a screen of death......Page 439
Summary......Page 440
Chapter 12: Hosting ASP.NET Core 3 Applications......Page 441
Hosting applications......Page 442
Deploying applications in AWS......Page 444
Deploying applications in AWS Elastic Beanstalk......Page 447
Getting the application running on AWS......Page 459
Deploying applications in Microsoft Azure......Page 472
Getting an Azure App Service instance running......Page 476
Publishing your code on Azure......Page 482
Continuous integration with Azure Repos......Page 483
Connecting the database......Page 486
Deployment through the Web Deploy tool......Page 493
Deploying applications into Docker containers......Page 496
Deploying applications into Docker containers ......Page 497
Publishing images to Docker Hub......Page 505
Summary......Page 508
Chapter 13: Managing ASP.NET Core 3 Applications......Page 509
Logging in ASP.NET Core 3 applications......Page 510
Logging in Microsoft Azure......Page 511
Enabling Microsoft Azure App Service......Page 512
Logging in AWS......Page 519
Monitoring ASP.NET Core 3 applications......Page 522
Monitoring on-premises and in Docker......Page 523
Monitoring in Microsoft Azure......Page 526
Monitoring in AWS......Page 542
Summary......Page 547
Other Books You May Enjoy......Page 548
Index......Page 551