FilterCollectionExtensions Class
Definition
- Namespace
- Cuemon.Extensions.AspNetCore.Mvc.Filters
- Assemblies
- Cuemon.Extensions.AspNetCore.Mvc.dll
Extension methods for the FilterCollection class.
public static class FilterCollectionExtensions
- Inheritance
-
objectFilterCollectionExtensions
Examples
The following example demonstrates how to use the FilterCollectionExtensions extension methods to register common ASP.NET Core MVC filters.
using Cuemon.Extensions.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace MyAspNetCoreApp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers(options =>
{
// Add HTTP cacheable filter for response caching
options.Filters.AddHttpCacheable();
// Add developer-friendly fault descriptor
options.Filters.AddFaultDescriptor();
// Add server timing header for performance profiling
options.Filters.AddServerTiming();
// Add User-Agent sentinel filter
options.Filters.AddUserAgentSentinel();
// Add API throttling sentinel
options.Filters.AddThrottlingSentinel();
// Add API key sentinel
options.Filters.AddApiKeySentinel();
});
}}
}
Methods
| Name | Description |
|---|---|
| AddApiKeySentinel(FilterCollection) | Adds an ApiKeySentinelFilter to the |
| AddFaultDescriptor(FilterCollection) | Adds a FaultDescriptorFilter to the |
| AddHttpCacheable(FilterCollection) | Adds a HttpCacheableFilter to the |
| AddServerTiming(FilterCollection) | Adds a ServerTimingFilter to the |
| AddThrottlingSentinel(FilterCollection) | Adds a ThrottlingSentinelFilter to the |
| AddUserAgentSentinel(FilterCollection) | Adds an UserAgentSentinelFilter to the |