I am trying to do some basic authentication in a WCF RequestInterceptor. I am using this article as a start.
The problem I am running into is communicating between the interceptor and the service. Nothing I have tried seems to work. So far, I have tried:
- OperationContext.Current
- requestContext.RequestMessage.Properties[HttpRequestMessageProperty.Name]["foo"] = value
- HttpContext.Current.Request
But no matter what I set, I can't seem to access it in the service behavior itself:
[AspNetCompatibilityRequirements( RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed )]
[ServiceBehavior( InstanceContextMode = InstanceContextMode.Single )]
public class AdvertiserService : ApiServiceBase<AdvertiserDataAccessor>, IAdvertiserService
{
[WebGet( UriTemplate = "" )]
public List<Advertiser> GetAdvertisers()
{
var request = HttpContext.Current.Request;
var headers = HttpContext.Current.Request.Headers;
var p = HttpContext.Current.Request.Headers["Principal"];
OperationContext ctx = OperationContext.Current;
}
}
My questions are:
How can I pass data between the Interceptor and the service?
Is there a canoncial way to pass auth information between them (note, the auth info is a UID in the database, not a Windows Identity)?
Thanks