Extract Custom Header Value From Web API Request

Here’s a simple C# extension method that returns the value of a custom header from a Web API request; it extends the HttpRequestMessage class:

Assuming you have a HttpRequestMessage object, you can call it as such:

var customHeaderValue = request.GetHeaderValue("Custom-Header");


Featured Image: All rights reserved by asienman


Leave a Reply

Your email address will not be published. Required fields are marked *