Using ASP.Net Web API 2, is it possible to get cookies from the AuthorizeAttribute filter
public class SessionFilter : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
// I need to read cookie values here
// filterContext.??getCookies??
}
}
To get the cookies from AuthorizationContext:
filterContext.HttpContext.Request.Cookies
Example in the method:
public class SessionFilter : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
// I need to read cookie values here
HttpCookie cookie = filterContext.HttpContext.Request.Cookies.Get("Cookie Name");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With