I'm having a bit of trouble with a WebAPI project using MVC5 and attribute routing.
Essentially, this is what I want to do:
[Route("Products/{CategoryId}")]
[ClaimsAuthorize([{CategoryId}], ClaimsEnum.CanViewProducts)]
public Products Get(){
...
}
Where [{CategoryId}] is where I want to pass the CategoryId to the attribute handler. The CustomAttribute handler looks like this:
public ClaimsAuthorizeAttribute(string CategoryId, params ClaimsEnum[] requiredClaimTypes)
Where ClaimsAuthorize is a custom attribute overriding the Authorize attribute.
How can I access the CategoryId parameter from the custom attribute? Is this possible? Or is there another way of passing it to the attribute handler?
This is pseudocode, but describes my problem. I need to know the category that is passed with the request URL when I'm processing the authorization. I know I can use headers, but I want to keep things visible in the URL if I can.
Thanks :)