Contents
Introduction 1
Version 1
Purpose 2
Who should use this guide 2
How you can use this guide 2
Characteristics of Modern Web Applications 3
Summary 3
Reference Application: eShopOnWeb 3
Cloud-Hosted and Scalable 4
Cross Platform 4
Modular and Loosely Coupled 5
Easily Tested with Automated Tests 5
Traditional and SPA Behaviors Supported 5
Simple Development and Deployment 6
Traditional ASP.NET and Web Forms 6
Choosing Between Traditional Web Apps and Single Page Apps (SPAs) 7
Summary 7
Project Templates 8
When to choose traditional web apps 10
When to choose SPAs 11
Decision table – Traditional Web or SPA 13
Architectural Principles 14
Summary 14
Common design principles 14
Separation of Concerns 14
Encapsulation 15
Dependency Inversion 15
Explicit Dependencies 17
Single Responsibility 17
Don’t Repeat Yourself (DRY) 18
Persistence Ignorance 19
Bounded Contexts 20
Common Web Application Architectures 21
Summary 21
What is a monolithic application? 21
All-in-One applications 21
What are layers? 22
Traditional “N-Layer” architecture applications 24
Clean architecture 28
Monolithic Applications and Containers 35
Monolithic application deployed as a container 36
Docker support 38
Common Client-Side Web Technologies 41
Summary 41
HTML 41
CSS 42
JavaScript 43
Legacy Web Apps with jQuery 43
jQuery vs a SPA Framework 43
Angular SPAs 44
React 45
Choosing a SPA Framework 45
Developing ASP.NET Core Apps 47
Summary 47
MVC and Razor Pages 47
Why Razor Pages? 48
When to use MVC 49
Mapping Requests to Responses 49
Working with Dependencies 51
Declare Your Dependencies 53
Structuring the Application 54
Feature Organization 55
Cross-Cutting Concerns 57
Security 60
Authentication 60
Authorization 62
Client Communication 65
Domain-Driven Design – Should You Apply It? 66
When Should You Apply DDD 67
When Shouldn’t You Apply DDD 67
Deployment 68
Working with Data in ASP.NET Core Apps 70
Summary 70
Entity Framework Core (for relational databases) 70
The DbContext 71
Configuring EF Core 71
Fetching and Storing Data 73
Fetching Related Data 74
Encapsulating Data 75
Resilient Connections 76
EF Core or micro-ORM? 78
SQL or NoSQL 80
Azure Cosmos DB 81
Other Persistence Options 82
Caching 82
ASP.NET Core Response Caching 83
Data Caching 83
Testing ASP.NET Core MVC Apps 87
Summary 87
Kinds of Automated Tests 87
Unit Tests 87
Integration Tests 88
Functional Tests 89
Testing Pyramid 90
What to Test 91
Organizing Test Projects 91
Test Naming 93
Unit Testing ASP.NET Core Apps 94
Integration Testing ASP.NET Core Apps 96
Functional Testing ASP.NET Core Apps 96
Development process for Azure-hosted ASP.NET Core applications 100
Vision 100
Development environment for ASP.NET Core apps 100
Development tools choices: IDE or editor 100
Development workflow for Azure-hosted ASP.NET Core apps 101
Initial Setup 101
Workflow for developing Azure-hosted ASP.NET Core applications 103
References 104
Azure Hosting Recommendations for ASP.NET Core Web Apps 105
Summary 105
Web Applications 105
App Service Web Apps 106
Containers and Azure Container Service 106
Azure Service Fabric 107
Azure Virtual Machines 107
Logical Processes 108
Data 108
Architecture Recommendations 108