Matias Cicero
Matias Cicero

Reputation: 26321

ASP.NET Web API - If-None-Match Request's header not being read

I'm having a problem in my application, where the browser is sending me a: If-None-Match header, and my server is not being able to fetch it.

Here is my confirmation:

IfNoneMatch not being fetched

And in here you can see, that, in fact, the header is being sent on the request:

("Encabezados de solicitud" is "Request's Headers" in spanish)

IfNoneMatch is being sent

Do you guys know what is probably the issue here? I'm out of ideas


Edit

I'm caching my OkNegotiatedContentResult in a MemoryCache in the server. The Http Cache is done afterwards, so it probably fetch the IHttpActionResult from the cache.

Therefore, the RequestMessage property is from the serialized IHttpActionResult.

Maybe, IfNoneMatch header is not serializable and therefore it was deserialized as null?.

Can this be confirmed?

Upvotes: 0

Views: 1143

Answers (1)

Matias Cicero
Matias Cicero

Reputation: 26321

Ok so, here was the deal.

As I said, I was caching the whole IHttpActionResult. This was WRONG. Because, that also meant I was caching the RequestMessage of that result.

Therefore, when I got the cached IHttpActionResult from the memory pool, I got the first IHttpActionResult with the first request that was cached.

That request may or may not have the IfNoneMatch header and is totally different from the browser's request I was inspecting, it was a past request.

Upvotes: 1

Related Questions