TypedRequestFilters not firing

I’m trying to set a typed request filter using an abstract class following this example.

The filter registers but never fires when a RequestDTO implementing my class is received. Here are the definitions:

/// abstract class to inherit from
public abstract class IAuditableRequest
{
    public string RequestedByUserId { get; set; }
}
/// Request DTO
public class CreateAThingRequest : IAuditableRequest
{
   // some props
}
/// registering the filter in AppHost.cs
RegisterTypedRequestFilter<IAuditableRequest>((req, res, dto) => {
    if (req.Verb != "GET" && req.Verb != "OPTIONS")
    {
        IAuthSession session = req.GetSession();
        dto.RequestedByUserId = session.UserAuthId;
    }
})   

If I register it as a GlobalRequestFilter and then compare the types it works but I’d prefer not to do this on every single request. It’s likely something simple but I’ve been troubleshooting for a good hour and decided it’s time to ask for help.

It either needs to be either the Request DTO Concrete Type or an Interface, so change IAuditableRequest to be an interface instead of an abstract class. Note you shouldn’t use Interface naming conventions for abstract classes.

OK makes sense. Maybe I’m using the wrong thing here? Was reading this SO post and it seems I might want to use a FilterAttribute instead?

Overall goal is to be able to set a RequestedByUserId property on any request DTO that needs to be audited without needing to add that prop. Using an interface and a request filter still requires me to implement the interface props on the request DTO. I’ve been in javascript land for a while and maybe I’m just getting my inheritance types confused and this isn’t possible?

I’d strongly recommend not thinking of Request DTO properties as something to Hide behind inheritance, their declarative and provide a single source of reference where the presence of properties provide clarity.

You can still use inheritance by having the abstract class implement the interface, otherwise you can pass any info throughout the Request pipeline using the IRequest.Items dictionary.