chapter fourteen

14 Configuring and publishing your application

 

This chapter covers

  • Understanding and managing environments
  • Managing application configuration with appSettings
  • Improving performance with Caching
  • Publishing your application

We got there! Well, almost. We’ve written our application and made sure it is secured against external threats. It’s virtually ready to go live, but there are one or two things we need to attend to first and this final chapter will wrap those up before walking through the publishing process.

The source of most issues that arise after an application has been deployed to a production web server is the difference between the development environment and the hosting environment. Various configurations such as database connection strings or mail server settings will often differ between the two environments. We will explore how ASP.NET Core helps you to manage the differences between these environments seamlessly using the environments concept that we have seen referred to a few times throughout this book. In addition, we will take a much closer look at the primary means for storing application configuration data - the appSettings.json file - and learn several ways in which we can read its contents at runtime.

14.1 Working with environments

14.1.1 Understanding and managing environments

14.1.2 Setting the environment

14.1.3 Register services conditionally for each environment

14.1.4 The IHostEnvironment service

14.1.5 The environment tag helper

14.2 Application configuration

14.2.1 AppSettings.json

14.2.2 Accessing configuration settings programmatically by key

14.2.3 Strongly typed appsettings

14.2.4 Using the options pattern

14.2.5 Binding directly to POCOs

14.2.6 Environments

14.3 Improving performance with caching

14.3.1 The cache tag helper

14.3.2 In-memory caching with IMemoryCache

14.4 Publishing your application

14.4.1 Self-contained and framework-dependent

14.4.2 Publish using the CLI

14.4.3 Publish using Visual Studio

14.5 Summary