I'm building a Windows Store App using the Windows Runtime. I'm accessing an OData service that uses Basic authentication. I'm using the WCF Data Services Tools for Windows Store Apps library (Microsoft.Data.Services.Client.WindowsStore
).
The authentication string is a custom format, so I can't just use a NetworkCredential(username, password)
. I need to add the header myself to every request from my DataServiceContext
.
I tried using the following code:
proxy.SendingRequest += (s, e) =>
{
e.RequestHeaders.Add("Authorization", authHeader);
}
But I receive the error:
'System.Net.WebHeaderCollection' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'System.Net.WebHeaderCollection' could be found