I need to add something to HostContext.RequestContext.Items at the very beginning of the request, and then I have to dispose it.
In OnEndRequestCallbacks it’s too late, and Items collection is empty.
GlobalResponseFilters would be OK, but they aren’t called when user is not authenticated for example.
The default behavior already disposes any IDisposable in IRequest.Items but you can override OnEndRequest() and do any cleanup before calling base.OnEndRequest(), e.g:
public override void OnEndRequest(IRequest request = null)
The Order of Operations shows the order when filters are executed, e.g. you can use PreRequestFilters. The Authenticate Request Filter Attribute has a priority of -100, so any Request Filter Attribute with a priority lower than that will execute before the [Authenticate] attribute.