Web Applications with ASP.NET Core Architecture and Patterns guidance (Updated for .NET Core 2.0)

Updated for ASP.NET Core 2.0 (Nov. 15th 2017)

Earlier this year, we published this eBook/Guide and sample application offering guidance for Architecting Modern Web Applications with ASP.NET Core and Microsoft Azure.

We have recently published updates to the eBook (2nd edition) and sample application to bring them in line with the latest releases of ASP.NET Core 2.0 and Entity Framework Core 2.0.

What’s new

The eBook/Guide has been updated to ASP.NET Core 2.0, .NET Standard Library 2.0 and Entity Framework 2.0 and .NET Core 2.0 in general, while referencing to the new code implemented in the updated sample app for ASP.NET Core 2, as well.

The sample application (eShopOnWeb) has been expanded to support additional functionality over what existed in the initial version. Specifically, in addition to allowing users to manage a shopping cart, log in, and check out, users can now view past orders. Orders also include shipping address data, which is implemented as a value object pattern using the new owned entities in EF Core 2.0.

All of the projects have been updated to the ASP.NET 2.0, netstandard 2.0, and EF Core 2.0, as appropriate.

Also, the identity management system has been updated to use the latest ASP.NET Identity 2.0 version, which includes built-in support for Two Factor Authentication (2FA) using an Authenticator app.

In addition, the sample now makes use of the Specification pattern to improve the design of its data access and better follow separation of concerns. These additional application features were added to help make the sample more “real world” in nature, providing more opportunities to demonstrate new features and techniques available in ASP.NET Core.

Finally, one of the new features added in ASP.NET Core 2.0 is Razor Pages, and so the eBook and the sample application have been updated to demonstrate side-by-side in separate web projects both a Razor Pages implementation and a Controllers-and-Views implementation of the same business application.

Details on updates targeting .NET Core 2.0

There a more extensive post placed in the eShopOnWeb GitHub repo explaining the details of the updates targeting .NET Core 2.0 for this architecture guidance and sample application.

Summary

With the availability of ASP.NET Core 2.0 and EF Core 2.0, it’s a great time to start building apps on .NET Core. Using these frameworks and tools, developers can follow well-established principles and practices to write high-quality, testable, and maintainable software.

Check out the extensive guidance offered in the Architecting Modern Web Applications with ASP.NET Core 2.0 and Azure eBook (2nd Edition)  referenced below and the associated eShopOnWeb sample application to learn more.



As part of the series of posts announced at this initial blog post (.NET Application Architecture Guidance) that explores each of the architecture areas currently covered by our team, this current blog post focuses on “Web Applications with ASP.NET Core Architecture and Patterns guidance“.

Just as a reminder, the four introductory blog posts of this series are (or will be as of today) the following: 

The previous blog post focused on Microservices architecture. However, even when microservices are great for certain scenarios explained in that previous blog post, for most of the medium-size application scenarios, you still will want to create regular web applications, also named “monolithic applications” because of their deployment style. Microservices shouldn’t be the new “silver bullet” to be used for everything but just for certain cases. Therefore, in many cases, you still will want to create regular/monolithic web applications but using modern approaches and modern technologies.

Introducing the ‘Architecting Modern Web Applications with ASP.NET Core and Microsoft Azure’ Guide/eBook

Building web applications with ASP.NET Core, hosted in Microsoft Azure, offers numerous competitive advantages over traditional alternatives.

ASP.NET Core is optimized for modern web application development practices and cloud hosting scenarios.

In this guide, you will learn how to architect your ASP.NET Core applications to best take advantage of these capabilities.

Free download: http://aka.ms/WebAppEbook


eBook author: Steve Smith

.NET Core and ASP.NET Core offer multiple advantages over traditional .NET development. You should use .NET Core for your server applications if some or all of the following are important to your application’s success:

  • Cross-platform support
  • Use of microservices
  • Use of Docker containers
  • High performance and scalability requirements
  • Side-by-side versioning of .NET versions by application on the same server

Traditional .NET applications can and do support some of these requirements, but ASP.NET Core and .NET Core have been optimized to offer improved support for the above scenarios.

More and more organizations are choosing to host their web applications in the cloud using services like Microsoft Azure. You should consider hosting your application in the cloud if the following are important to your application or organization:

  • Reduced investment in data center costs (hardware, software, space, utilities, etc)
  • Flexible pricing (pay based on usage, not for idle capacity)
  • Extreme reliability
  • Improved app mobility; easily change where and how your app is deployed
  • Flexible capacity; scale up or down based on actual needs

Who should use this guide

We wrote this guide for developers and solution architects who are new to ASP.NET Core while looking to learn and adopt a specific web application architecture applying proven patterns and best practices.
You will also find this guide useful if you are a technical decision maker, such as an architect, who wants an architecture and technology overview before you decide on what approach to select for new and modern web applications.

Related sample ASP.NET Core web application: eShopOnWeb

The eShopOnWeb application (still in BETA state) is a sample reference web app based on ASP.NET Core. This application is open source and available at the  eShopOnWeb GitHub repo.

The following diagram shows a high-level overview of the internal architecture of the sample ASP.NET Core web application:


The fact that a web application can have a monolithic deployment doesn’t mean that its internal design is also monolithic or “spaghetti code”.

Applications that follow the Dependency Inversion Principle as well as Domain-Driven Design (DDD) principles tend to arrive at a similar architecture. This architecture has gone by many names over the years. One of the first names was Hexagonal Architecture, followed by Ports-and-Adapters. More recently, it’s been cited as the Onion Architecture or Clean Architecture. It is this last name, Clean Architecture, that is used as the basis for describing the architecture in this eBook.

Clean architecture puts the business logic and application model at the center of the application.

Instead of having business logic depend on data access or other infrastructure concerns, this dependency is inverted: infrastructure and implementation details depend on the Application Core.

Here’s another view of an ASP.NET Core monolithic web application using multiple components related.


 

Visit the .NET Application Architecture Center and grab it all!

Remember that this ‘Web Applications with ASP.NET Core Architecture and Patterns guidance’ explained at this blog post is part of a broader .NET Architecture guidance which covers additional subjects and you can check out at the .NET Application Architecture Center page where you can download the multiple eBooks/Guides and visit the reference applications from there, and of course, feel free to provide feedback by dropping a note below or on the feedback form at the architecture page.

image

Happy coding from the .NET team!

Cesar de la Torre

.NET Product Group

Twitter: @cesardelatorre