문제

I am busy implementing and Authentication filter:

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"];

How do I get the header called token ? Because the above code doesn't work. I am guessing this is because its not a standard header.

도움이 되었습니까?

해결책

request.Headers.GetValues("token");

다른 팁

You should actually use

request.Headers.Authorization.Parameter;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top