ASP.NET Core is a powerful web framework that allows developers to build robust and scalable web applications. Two important concepts in ASP.NET Core are middleware and filters. Both of these concepts are used to add functionality to an application, but they are used in different ways and for different purposes.
Middleware is a component that sits in between the application and the server. It is responsible for handling requests and responses and can be used to add functionality such as authentication, logging, and routing. Middleware is executed in a specific order and can be used to handle multiple requests and responses.
On the other hand, filters are used to add functionality to specific actions or controllers. They can be used to add functionality such as authorization, exception handling, and caching. Filters run within the ASP.NET Core action invocation pipeline, sometimes referred to as the filter pipeline. The filter pipeline runs after ASP.NET Core selects the action to execute. Filters are executed before or after an action is executed and can be used to modify the request or response.

Both middleware and filters can be used to add functionality to an application. However, middleware is used for global functionality that applies to all requests, while filters are used for specific functionality that applies to specific actions or controllers. The main difference between them is their scope. Filters are a part of MVC, so they are scoped entirely to the MVC middleware.
In summary, middleware is used for global functionality that applies to all requests, while filters are used for specific functionality that applies to specific actions or controllers. Middleware is executed in a specific order, while filters are executed before or after an action is executed. Both middleware and filters can be used to add functionality to an application, but they are used in different ways and for different purposes.
Read more here