Skip to content

HttpGetOrPostAttribute Class

Specifies that an action supports both HTTP GET and POST methods.

C#
public class HttpGetOrPostAttribute : Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute

Inheritance System.ObjectSystem.AttributeMicrosoft.AspNetCore.Mvc.Routing.HttpMethodAttribute → HttpGetOrPostAttribute

Remarks

This attribute can be applied to an action method to indicate that it should respond to HTTP GET and POST requests. When applied to an action method, it specifies that the method handles requests made with these two HTTP methods. It can be used to support scenarios where a resource can be fetched (GET) or submitted (POST) to the same URL.

Constructors

HttpGetOrPostAttribute() Constructor

Initializes a new instance of the HttpGetOrPostAttribute class without specifying a route template.

C#
public HttpGetOrPostAttribute();

HttpGetOrPostAttribute(string) Constructor

Initializes a new instance of the HttpGetOrPostAttribute class with the specified route template.

C#
public HttpGetOrPostAttribute(string template);

Parameters

template System.String

The route template. The template may define path segments, parameters, etc., as per routing conventions.