You can find the values in authorizationContext.RequestContext.HttpContext
or if planId
is part of the route you can even find it in authorizationContext.RequestContext.RouteData
.
Passing a parameter from control to custom Authorization
-
17-06-2023 - |
Question
I am creating a class that derive from AuthorizeAttribute
class. I need to pass the parameter in my controller, where I decorate the derive class. How can I achieve that in this situation?
[SampleAuthorization]
public ActionResult GetFileContent(Guid planId)
{
}
public class PlanAuthorizationAttribute : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
// how can I use my planId to my custom plan authorizaton
base.OnAuthorization(filterContext);
}
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow