Course Overview

.NET Core is Microsoft’s latest cross platform, open source implementation of .NET.  It can run on Windows, Linux, and Mac operating systems, and on a variety of different devices.  Similarly, ASP.NET Core, originally referred to as ASP.NET 5, represents the current and future platform for web applications in .NET, and provides cross platform support with flexible hosting options.

This class introduces developers who are already familiar with .NET and web development to the new features and best practices of developing for .NET Core.  The primary emphasis is on presenting what is new in .NET Core and on highlighting the differences versus .NET Framework.

This course can be covered in 3 days without labs, and 4-5 days with full labs.

Key Learning Areas

  • What is .NET Core and why write applications for it?
  • How to use both the command line and Visual Studio to develop for .NET Core
  • The deployment options for a .NET Core application
  • The structure of an ASP.NET Core application
  • Dependency Injection in ASP.NET Core
  • The new way of specify and parsing configuration settings
  • The differences between Entity Framework and Entity Framework Core
  • Best practices for data access in .NET Core using Repository and Unit of Work Patterns
  • Startup and middleware code in ASP.NET Core
  • How to unit test an ASP.NET Core controller using xUnit , Moq, and the new in memory database
  • The new MVC Core view features: tag helpers and view components
  • Migrating a .NET framework application to .NET Core
  • How to effectively use familiar web tools, specifically gulp, grunt & bower, in Visual Studio

Course Outline

.NET Core

The course begins with a general introduction to the architecture of .NET Core, and the tools and deployment options for building any type of application.

  • What is .NET Core and why write applications for it
  • How to use both the command line and Visual Studio to develop for .NET Core
  • The deployment options for a .NET Core application

ASP.NET Core

Web development requires a thorough understanding of ASP.NET Core, and this module covers the anatomy of an ASP.NET core application.

  • Architecture of ASP.NET Core
  • Startup and middleware

ASP.NET Core Web API

This module introduces Web API, the de facto framework for building HTTP-based RESTful services. We will cover the motivation for HTTP oriented services as an alternative to SOAP-based services. We will examine the architecture of an ASP.NET Core Web API application, including attribute and convention based routing, and discuss the new features introduced in ASP.Net Core 2.1, the APIControllerAttribute and the ActionResult<T> return type.

  • REST Basics
  • Web API controllers
  • Web API action methods: returning a specific type, IActionResult, and ActionResult<T>
  • Web API routing
  • The new APIControllerAttribute
  • CRUD operations
  • .NET Web API Client

Repository and Unit of Work Patterns

Data access technologies have their own specific APIs.  Writing application logic against these APIs is a form of corruption - you are now wedded to that data access technology. In addition, testing the application logic in isolation from the data store becomes difficult.  The Repository and Unit of Work Patterns isolate your application from the underlying data store by abstracting away its details.

  • How to separate application logic from data access

Dependency Injection

Tightly coupled systems are less flexible because they make it difficult to swap out components should they become outdated or should you wish to replace them.  In addition, your code becomes less testable, because unit tests are unable to replace dependencies with fakes, turning unit tests into integration tests, which are slower and prone to breakage.  You’ll learn how to address these issues with the ASP.NET Core built-in dependency injection container.

  • Dependency Injection in ASP.NET Core
  • Constructor and method injection
  • Lifetime models: singleton vs. transient vs. scoped
  • Creating services and injecting them into a web application

.NET Core Configuration

.NET Core configuration files operate differently from the traditional app.config and web.config files from .NET Framework.  In a .NET Core application, configuration information is typically specified with json format using an appSettings.json file.  This module demonstrates how configuration files are formatted and parsed in a .NET Core application.

  • Initialization and retrieval from the .NET Core configuration file
  • Binding and reloading

Mocking with Moq

In this session, we’ll introduce test doubles and show how mocking frameworks make it easier to stub out external dependencies.  The details of Moq are presented, which is the de facto standard mocking framework for .NET Core.

  • State vs Behavior verification
  • The different forms of Test Doubles
  • MOQ as an example of a mocking framework
  • Stubs: Properties and Methods
  • Mocks: Strict, Loose, and Partial

Unit Testing

Testing is a critical aspect of the software development process, and xUnit is the de facto testing framework for .NET Core.  This module represents the culmination of the material covered in this course, by showing how to use xUnit to test an ASP.NET Core Web API Controller with mock data created using Moq.

  • Using xUnit with Visual Studio
  • xUnit and Moq
  • Testing code that generates exceptions
  • Testing an ASP.NET Core Controller

Tools

This module demonstrates how to use Visual Studio with Web Development tools.

  • Gulp
  • Grunt
  • Bower

Migration

This module discusses how to migrate an existing .NET application to .NET Core.

  • Strategies and tools for porting an existing application
  • Discontinued technologies in .NET Core
  • Porting an ASP.NET Core Controller to .NET Core

Who Benefits

This class introduces developers who are already familiar with .NET and web development to the new features and best practices of developing for .NET Core.  The primary emphasis is on presenting what is new in .NET Core and on highlighting the differences versus .NET Framework.

Prerequisites

The expected audience for this course is C# developers with at least 6 months experience.