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);
    }
}
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top