In ASP.NET Core, a middleware component is a class that implements the IMiddleware interface or is a class that has a method named Invoke or InvokeAsync. To create a custom middleware component, you can create a new class and implement the InvokeAsync method. Here is an example of a custom middleware component that logs the request and response information: public class RequestResponseLoggingMiddleware { private readonly RequestDelegate _next; public RequestResponseLoggingMiddleware (RequestDelegate next) { _next = next; } public async Task InvokeAsync(HttpContext context) { // Log the request information var request = context.Request; Console.WriteLine( $" {request.Method} {request.Path} " ); foreach (var header in request.Headers) { Console.WriteLine( $" {header.Key} : {header.V