Share via


RouteConstraintBuilder.AddConstraint(String, Object) Method

Definition

Adds a constraint instance for the given key.

public:
 void AddConstraint(System::String ^ key, System::Object ^ value);
public void AddConstraint (string key, object value);
member this.AddConstraint : string * obj -> unit
Public Sub AddConstraint (key As String, value As Object)

Parameters

key
String

The key.

value
Object

The constraint instance. Must either be a string or an instance of IRouteConstraint.

Remarks

If the value is a string, it will be converted to a RegexRouteConstraint.

For example, the string Product[0-9]+ will be converted to the regular expression ^(Product[0-9]+). See Regex for more details.

Applies to