How to extract custom header value?

Request.Headers returns Microsoft.AspNetCore.Http.IHeaderDictionary interface that define next property:

StringValues this[string key] { get; set; }

IHeaderDictionary has a different indexer contract than IDictionary, where it will return StringValues.Empty for missing entries.

Return type: Microsoft.Extensions.Primitives.StringValues

Returns: The stored value, or StringValues.Empty if the key is not present.

So, you can simply use Request.Headers["environment"] to get value of “environment” header

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)