Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get the Authorization header from wcf request interceptor

Tags:

wcf

I need to authenticate every request to wcf services


 public class AuthenticationInterceptor : RequestInterceptor
    {
        public AuthenticationInterceptor() : base(false)
        {
        }

        public override void ProcessRequest(ref System.ServiceModel.Channels.RequestContext requestContext)
        {
          //How to access Request Header (Authorization header) from here?
        }
    }

like image 833
h3n Avatar asked Sep 25 '11 23:09

h3n


1 Answers

You can get the headers from the System.ServiceModel.Channels.Message, so try

var message = requestContext.RequestMessage;
var request = (HttpRequestMessageProperty)message.Properties[HttpRequestMessageProperty.Name];

string authorization = request.Headers[HttpRequestHeader.Authorization];
like image 185
Jeff Ogata Avatar answered Oct 01 '22 09:10

Jeff Ogata