Implementing advanced features
Since the third edition of this book, published in late 2017, Microsoft has added lots of great features to ASP.NET for building web services.
Implementing Health Check API
There are many paid services that perform site availability tests that are basic pings, some with more advanced analysis of the HTTP response.
ASP.NET Core 2.2 and later makes it easy to implement more detailed website health checks. For example, your website might be live, but is it ready? Can it retrieve data from its database?
- Open
NorthwindService.csproj
. - Add a project reference to enable Entity Framework Core database health checks, as shown in the following markup:
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.0.0" />
- In Terminal, restore packages and compile the website project, as shown in the following command:
dotnet build
- Open
Startup.cs
. - In the
ConfigureServices...