HttpMethodAttribute Class

Identifies an action that only supports a given set of HTTP methods.

Namespace
Microsoft.AspNetCore.Mvc.Routing
Assemblies
  • Microsoft.AspNetCore.Mvc.Core

Syntax

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class HttpMethodAttribute : Attribute, _Attribute, IActionHttpMethodProvider, IRouteTemplateProvider
class Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute

Constructors

HttpMethodAttribute(System.Collections.Generic.IEnumerable<System.String>)

Creates a new Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute with the given set of HTTP methods. <param name=”httpMethods”>The set of supported HTTP methods.</param>

public HttpMethodAttribute(IEnumerable<string> httpMethods)
HttpMethodAttribute(System.Collections.Generic.IEnumerable<System.String>, System.String)

Creates a new Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute with the given set of HTTP methods an the given route template.

Arguments:
  • httpMethods (System.Collections.Generic.IEnumerable<System.String>) – The set of supported methods.
  • template (System.String) – The route template. May not be null.
public HttpMethodAttribute(IEnumerable<string> httpMethods, string template)

Properties

Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute.HttpMethods
Return type:System.Collections.Generic.IEnumerable<System.String>
public IEnumerable<string> HttpMethods { get; }
Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute.Order
Return type:System.Nullable<System.Int32>
int ? IRouteTemplateProvider.Order { get; }
Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute.Name
Return type:System.String
public string Name { get; set; }
Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute.Order

Gets the route order. The order determines the order of route execution. Routes with a lower order value are tried first. When a route doesn’t specify a value, it gets the value of the Microsoft.AspNetCore.Mvc.RouteAttribute.Order or a default value of 0 if the Microsoft.AspNetCore.Mvc.RouteAttribute doesn’t define a value on the controller.

Return type:System.Int32
public int Order { get; set; }
Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute.Template
Return type:System.String
public string Template { get; }