Header reading in WebApi

0

I have a code that makes a post for a url and adds some parameters to the request Header

HttpWebRequest req = WebRequest.Create(new Uri(url)) as HttpWebRequest;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.Headers.Add("Cache-Control", "no-cache");
req.Headers.Add("X-ICM-API-Authorization", token);

How do I code to read these parameters that are in the header in the Web API?

    
asked by anonymous 15.09.2016 / 04:38

1 answer

1

If your controller inherits from ApiController , you can retrieve the headers from the request through the Request property, which in turn has an Headers .

In the specific case of authentication / authorization I suggest using a Message Handler .

    
15.11.2016 / 16:47