HttpContext.Current is null in my web service
If you want to use HttpContext
because the code has already been written as so; you need to add this to your web.config where your service resides:
<configuration>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
Correct else use below to read header
var headers = OperationContext.Current.IncomingMessageProperties["httpRequest"];
var apiToken = ((HttpRequestMessageProperty)headers).Headers["apiKey"];
From one of Microsoft's pages on the subject.
HttpContext: Current is always null when accessed from within a WCF service. Use RequestContext instead.