我正忙着实施和验证过滤器:
public Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken)
{
var request = context.Request;
// Receive token from the client. Here is the example when token is in header:
var token = request.Headers.FirstOrDefault(x => x.Key == "Token").Value.ToString(); //["Token"];
如何获取名为token的标头?因为上面的代码不起作用。我猜这是因为它不是标准的标题。
答案 0 :(得分:3)
request.Headers.GetValues("token");
答案 1 :(得分:0)
你应该实际使用
request.Headers.Authorization.Parameter;