gpt4 book ai didi

wcf - 如何从 wcf 请求拦截器获取授权 header

转载 作者:行者123 更新时间:2023-12-04 17:56:43 25 4
gpt4 key购买 nike

我需要验证对 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 获取标题。 ,所以试试

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

string authorization = request.Headers[HttpRequestHeader.Authorization];

关于wcf - 如何从 wcf 请求拦截器获取授权 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7549368/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com