Export (0) Print
Expand All

IRouteConstraint.Match Method

Determines whether the URL parameter contains a valid value for this constraint.

Namespace:  System.Web.Routing
Assembly:  System.Web (in System.Web.dll)

bool Match(
	HttpContextBase httpContext,
	Route route,
	string parameterName,
	RouteValueDictionary values,
	RouteDirection routeDirection


Type: System.Web.HttpContextBase

An object that encapsulates information about the HTTP request.

Type: System.Web.Routing.Route

The object that this constraint belongs to.

Type: System.String

The name of the parameter that is being checked.

Type: System.Web.Routing.RouteValueDictionary

An object that contains the parameters for the URL.

Type: System.Web.Routing.RouteDirection

An object that indicates whether the constraint check is being performed when an incoming request is being handled or when a URL is being generated.

Return Value

Type: System.Boolean
true if the URL parameter contains a valid value; otherwise, false.

You use the Match method to add validation logic for the constraint. This method is called by the routing framework when an incoming request is processed and when a URL is constructed. You can determine the current scenario by examining the routeDirection parameter.

When a request is processed, the routing framework determines whether the pattern and values of the incoming request match the pattern and constraints of the route. When a URL is constructed, the routing framework determines whether the values supplied when the GetVirtualPath method is called match the pattern and constraints of the route.

.NET Framework

Supported in: 4.5, 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft