IRouteConstraint IRouteConstraint IRouteConstraint IRouteConstraint Interface

定義

定義類別必須實作的成員,才能檢查 URL 參數值是否對條件約束 (Constraint) 有效。Defines the contract that a class must implement in order to check whether a URL parameter value is valid for a constraint.

public interface class IRouteConstraint
public interface IRouteConstraint
type IRouteConstraint = interface
Public Interface IRouteConstraint
衍生

備註

當您在路由定義中包含 URL 參數的條件約束時,任一字串也會實作的物件,您必須代表條件約束IRouteConstraint介面。When you include a constraint for a URL parameter in a route definition, you must represent the constraint as either string or as an object that implements the IRouteConstraint interface. 如果條件約束是字串,它會被視為規則運算式。If the constraint is a string, it is treated as a regular expression. 建立可實作類別IRouteConstraint時您不能代表驗證邏輯輕鬆做為規則運算式。You create a class that implements IRouteConstraint when you cannot represent the validation logic easily as a regular expression. 您加入驗證邏輯,在Match方法。You add the validation logic in the Match method.

方法

Match(HttpContextBase, Route, String, RouteValueDictionary, RouteDirection) Match(HttpContextBase, Route, String, RouteValueDictionary, RouteDirection) Match(HttpContextBase, Route, String, RouteValueDictionary, RouteDirection) Match(HttpContextBase, Route, String, RouteValueDictionary, RouteDirection)

判斷 URL 參數是否包含對這個條件約束有效的值。Determines whether the URL parameter contains a valid value for this constraint.

適用於

另請參閱