ResponseFilterAttrubutes and Not Modified results

We’ve been using Not-Modified responses for a while now and have just recently added a custom ResponseFilterSttribute that adds a response header.

However, we are finding when the server returns the 304 not modified the header isn’t getting returned.

Our services are doing this by throwing

 throw HttpAdditionalExtensions.PreconditionFailed("Cannot Update");

What might we be misunderstanding with the ability to return the custom header (which may actually have a different value). It’s basically a rate-limit remaining header.

Who’s returning the 304 header? and is the custom header set before the request is ended with a 304?

Sorry, i just realized that exception was one we wrote… basically we return the 304 via

 new HttpError(HttpStatusCode.PreconditionFailed, description);

from our service method. So, I’m assuming perhaps the custom filter isn’t being applied? Is there a way to force it or otherwise?

Right, so it’s obvious now. The HttpError stops processing responsefilters of any kind. So that makes sense.

It seems from what I can find, that I will have to set the headers in that HttpError object if i want them returned?

Or otherwise have them set before the Exception is thrown, e.g. in a Request Filter with res.AddHeader(name,value)