I am creating an custom action filter in which I am trying to check if there is a key ‘Authorization’ in the request header or not. If it is there, whether it contains a value ‘Bearer’ or not. I tried something like this::
public class CustomAuthFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string data;
var x=filterContext.HttpContext.Request.Headers.TryGetValue("Authorization",out data);
//what to do here
}
}
How do I do this?