我需要验证对wcf服务的每个请求 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? } }
最佳答案
您可以从System.ServiceModel.Channels.Message
获取 header ,因此请尝试
var message = requestContext.RequestMessage;
var request = (HttpRequestMessageProperty)message.Properties[HttpRequestMessageProperty.Name];
string authorization = request.Headers[HttpRequestHeader.Authorization];
关于wcf - 如何从wcf请求拦截器获取Authorization header ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7549368/