Implementing advanced features for web services
Now that you have seen the fundamentals of building a web service and then calling it from a client, let's look at some more advanced features.
Implementing a 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?
Let's add basic health check capabilities to our web service:
- In the
Northwind.WebApi
project, 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="6.0.0" />
- Build the project. ...