'X-Correllation-ID' header does not present in the Request.Headers colection
vhorodnii opened this issue · comments
Hi,
I have a question about correlation Id. I would like to use this id to save uploaded file with the same name, process it, and delete after processing.
In the action method I added [FromHeader(Name = "X-Correllation-ID")] Guid? correlationId
parameter but it is empty. I suppose that this value will have correlation id value, set by your package.
Also I checked Request.Headers
collection in action method. It also does not contain correlation header.
I found another way to do it: inject ICorrelationContextAccessor
to my controller and get value from correlation context. However, I would like to add parameter to my action method rather than injecting ICorrelationContextAccessor
component in my controller.
Is it achievable or not?
Thanks.
Hi @vhorodnii,
The library itself will not modify request headers. If you supply a correlation ID from the client (caller) as a header, then it will be used as the correlation ID and also available in the headers collection. If no ID is present, the library will create one. In that case, it will only be accessible via the injected accessor. I'd recommend using the injected ICorrelationContextAccessor
as it's a consistent approach, regardless of whether the caller provided a header or not.
Steve
Thank you for your explanation! I close this thread.