IActionConstraint Interface

Definition

Supports conditional logic to determine whether or not an associated action is valid to be selected for the given request.

public interface class IActionConstraint : Microsoft::AspNetCore::Mvc::ActionConstraints::IActionConstraintMetadata
public interface IActionConstraint : Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraintMetadata
type IActionConstraint = interface
    interface IActionConstraintMetadata
Public Interface IActionConstraint
Implements IActionConstraintMetadata
Derived
Implements

Remarks

Action constraints have the secondary effect of making an action with a constraint applied a better match than one without.

Consider two actions, 'A' and 'B' with the same action and controller name. Action 'A' only allows the HTTP POST method (via a constraint) and action 'B' has no constraints.

If an incoming request is a POST, then 'A' is considered the best match because it both matches and has a constraint. If an incoming request uses any other verb, 'A' will not be valid for selection due to it's constraint, so 'B' is the best match.

Action constraints are also grouped according to their order value. Any constraints with the same group value are considered to be part of the same application policy, and will be executed in the same stage.

Stages run in ascending order based on the value of Order. Given a set of actions which are candidates for selection, the next stage to run is the lowest value of Order for any constraint of any candidate which is greater than the order of the last stage.

Once the stage order is identified, each action has all of its constraints in that stage executed. If any constraint does not match, then that action is not a candidate for selection. If any actions with constraints in the current state are still candidates, then those are the 'best' actions and this process will repeat with the next stage on the set of 'best' actions. If after processing the subsequent stages of the 'best' actions no candidates remain, this process will repeat on the set of 'other' candidate actions from this stage (those without a constraint).

Properties

Order

The constraint order.

Methods

Accept(ActionConstraintContext)

Determines whether an action is a valid candidate for selection.

Applies to