Architecting Modern Web Apps with ASP.NET Core 2 and Azure
Total Page:16
File Type:pdf, Size:1020Kb
EDITION v2.0 DOWNLOAD available at: https://aka.ms/webappebook PUBLISHED BY DevDiv, .NET and Visual Studio product teams A division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2017 by Microsoft Corporation All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. This book is provided “as-is” and expresses the author’s views and opinions. The views, opinions and information expressed in this book, including URL and other Internet website references, may change without notice. Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred. Microsoft and the trademarks listed at http://www.microsoft.com on the “Trademarks” webpage are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. Author: Steve Smith (http://ardalis.com) Participants and reviewers: Scott Hanselman, .NET product team, Microsoft Cesar de la Torre, .NET product team, Microsoft 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 i 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 ..................................................................................................................... 34 Monolithic application deployed as a container ................................................................................................. 36 Common Client-Side Web Technologies .............................................................................................. 38 Summary .................................................................................................................................................................................. 38 HTML ......................................................................................................................................................................................... 38 CSS .............................................................................................................................................................................................. 39 JavaScript ................................................................................................................................................................................. 40 Legacy Web Apps with jQuery .................................................................................................................................... 40 jQuery vs a SPA Framework ......................................................................................................................................... 40 Angular SPAs...................................................................................................................................................................... 41 React .....................................................................................................................................................................................