views:

2356

answers:

2

This is in relation to this question

I am hosting this WCF service in a custom service host. IIS is not an option.

Is there a way to inject an HTTP "Authenticate" header in the server stack (if it's missing) early on in the request process - such that a default user can be passed into the authentication/authorization process that I have in place for anonymous requests?

I need the SERVER to inject this on the receiving end - before further WCF processing...

I'm pretty sure I can do this with a custom BindingElement, or by extending the WebHttpBinding, but any examples or guidance would be greatly appreciated. I can't find any examples of early header manipulation (pre authentication) in WCF.

A: 

I would type this out, but its a lot. So here is a good reference.

Avner Kashtan's blog post outlines what I "think" you're looking for. Hopefully this helps!

Adding Custom Headers To Every WCF Call

Donn Felker
that is adding headers to outgoing wcf calls. I need to add headers to INCOMING wcf calls.
TheSoftwareJedi
+1  A: 

By implementing an IDispatchMessageInspector you can plug into the pipeline server side; and manipulate messages.

In the AfterReceiveRequest method you can add to Request.Headers quite happily.

Wrap it with a behaviour attribute and apply it to your service.

blowdart