How to get argument in action filter when the controller action has no corresponding argument?

You can access the query-string values using HttpContext.Request.Query. Here's an example:

var tenantValues = context.HttpContext.Request.Query["tenant"];

The type of tenantValues here is StringValues, which represents one or more values. If you know there's only going to be one value provided, you can treat it as a collection and use [0] or First(), for example, or just case it as string.


You can use HttpContext property of ActionContext (which is ancestor of ActionExecutingContext) to access request query string values:

public override Task OnActionExecutionAsync(ActionExecutingContext actionContext, ActionExecutionDelegate next)
{
    StringValues values = actionContext.HttpContext.Request.Query["tenant"];
}