I have a controller which should only request authorization when loaded with specific parameters. Like when the parameter ID is 8 for example.
I came up with using a
You need something like this.
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
int? id = GetId(filterContext);
if (id.HasValue)
{
...
}
}
private static int? GetId(ActionExecutingContext filterContext)
{
int? Id = null;
if (filterContext.ActionParameters.ContainsKey("Id"))
{
Id = (int?)filterContext.ActionParameters["Id"];
}
}