You can access the request headers or modify the response headers easily inside the controller in your ASP.NET Core applications.
Add custom header to response
 Response.Headers.Add("your-custom-header-id", custom_header_value);Get a request header value
 var yourHeader = Request.Headers["your-custom-header-id"].FirstOrDefault();Get bearer token value
Another example where we get the bearer token from the Authorization header,
var authHeader = Request.Headers["Authorization"].FirstOrDefault();
if (authHeader != null && authHeader.StartsWith("Bearer", StringComparison.OrdinalIgnoreCase))
{
    var loginToken = authHeader.Replace("Bearer ", string.Empty, StringComparison.OrdinalIgnoreCase);
}








