HttpMethodRouteConstraint Class

Constrains the HTTP method of request or a route.

Namespace
Microsoft.AspNetCore.Routing.Constraints
Assemblies
  • Microsoft.AspNetCore.Routing

Syntax

public class HttpMethodRouteConstraint : IRouteConstraint
class Microsoft.AspNetCore.Routing.Constraints.HttpMethodRouteConstraint

Constructors

HttpMethodRouteConstraint(System.String[])

Creates a new Microsoft.AspNetCore.Routing.Constraints.HttpMethodRouteConstraint that accepts the HTTP methods specified by <em>allowedMethods</em>.

Arguments:allowedMethods (System.String<System.String>[]) – The allowed HTTP methods.
public HttpMethodRouteConstraint(params string[] allowedMethods)

Properties

Microsoft.AspNetCore.Routing.Constraints.HttpMethodRouteConstraint.AllowedMethods

Gets the HTTP methods allowed by the constraint.

Return type:System.Collections.Generic.IList<System.String>
public IList<string> AllowedMethods { get; }

Methods

Match(Microsoft.AspNetCore.Http.HttpContext, Microsoft.AspNetCore.Routing.IRouter, System.String, Microsoft.AspNetCore.Routing.RouteValueDictionary, Microsoft.AspNetCore.Routing.RouteDirection)
Return type:System.Boolean
public virtual bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)