I have this exact code from the accepted answer in my project which I need to migrate into ASP.NET Core MVP.
How to extract custom header value in Web API message ha
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