Class HttpMethodConstraint
Enables you to define which HTTP verbs are allowed when ASP.NET routing determines whether a URL matches a route.
public class HttpMethodConstraint : IHttpRouteConstraint
- Inheritance
-
HttpMethodConstraint
- Implements
- Inherited Members
Constructors
HttpMethodConstraint(params HttpMethod[])
Initializes a new instance of the HttpMethodConstraint class by using the HTTP verbs that are allowed for the route.
public HttpMethodConstraint(params HttpMethod[] allowedMethods)
Parameters
allowedMethods
HttpMethod[]The HTTP verbs that are valid for the route.
Properties
AllowedMethods
Gets or sets the collection of allowed HTTP verbs for the route.
public Collection<HttpMethod> AllowedMethods { get; }
Property Value
- Collection<HttpMethod>
A collection of allowed HTTP verbs for the route.
Methods
Match(HttpRequestMessage, IHttpRoute, string, IDictionary<string, object>, HttpRouteDirection)
Determines whether the request was made with an HTTP verb that is one of the allowed verbs for the route.
protected virtual bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary<string, object> values, HttpRouteDirection routeDirection)
Parameters
request
HttpRequestMessageThe request that is being checked to determine whether it matches the URL.
route
IHttpRouteThe object that is being checked to determine whether it matches the URL.
parameterName
stringThe name of the parameter that is being checked.
values
IDictionary<string, object>An object that contains the parameters for a route.
routeDirection
HttpRouteDirectionAn object that indicates whether the constraint check is being performed when an incoming request is processed or when a URL is generated.
Returns
- bool
When ASP.NET routing is processing a request, true if the request was made by using an allowed HTTP verb; otherwise, false. When ASP.NET routing is constructing a URL, true if the supplied values contain an HTTP verb that matches one of the allowed HTTP verbs; otherwise, false. The default is true.