Nextended.ResponseFilters.AspNetCore
📚 Full API reference — every public type and member, generated from the compiled assembly.
ASP.NET Core adapter for Nextended.ResponseFilters — registers the pipeline as a global IAsyncResultFilter and replays structural edits against the serialized JSON tree.
Installation
dotnet add package Nextended.ResponseFilters.AspNetCoreASP.NET Core adapter for Nextended.ResponseFilters. Wires the response-filter pipeline into MVC as a global IAsyncResultFilter — every ObjectResult.Value runs through the configured filters before serialization.
Installation
dotnet add package Nextended.ResponseFilters.AspNetCoreQuick Start
Define a filter (see Nextended.ResponseFilters for the full API):
public class OrderResponseFilter : ResponseFilter<OrderDto>
{
public OrderResponseFilter()
{
Nullify(x => x.TotalCost).Unless(WhenContext(ctx =>
ctx.Services.GetRequiredService<ICurrentUser>().IsInRole("Finance")));
}
}Wire it up once in Program.cs:
builder.Services.AddNextendedResponseFilters(new[]
{
typeof(OrderResponseFilter).Assembly
});That's it — every controller that returns an OrderDto (or anything containing one) now ships through the pipeline before serialization.
What it does
HTTP request
↓
[ … middleware … ]
↓
Controller action → ObjectResult { Value = OrderDto }
↓
ResponseFilterResultFilter (IAsyncResultFilter)
→ IResponseFilterPipeline.ProcessAsync(value, ctx)
→ walks the graph, applies registered filters
↓
JSON serializer
↓
HTTP responseThe result filter is registered globally via MvcOptions.Filters.AddService<ResponseFilterResultFilter>(). Failures inside the pipeline are caught and logged — a buggy rule cannot 500 a request.
Notes
- The
IResponseFilterContexthanded to predicates hasHttpContext.RequestServicesandHttpContext.RequestAbortedpre-wired. - Filter scope follows the request scope by default. Override via the
lifetimeparameter ofAddNextendedResponseFiltersif needed. - If you also use ABP / FluentValidation / OData — the filter sits after model binding and before serialization, so it composes cleanly with all of them.
Supported frameworks
net8.0net9.0net10.0
Dependencies
- Nextended.ResponseFilters