Table of Contents

Class MethodNotAllowedError

Namespace
Trellis
Assembly
Trellis.Results.dll

Represents a method not allowed error when the HTTP method is not supported for the target resource. Maps to HTTP 405 Method Not Allowed.

public sealed class MethodNotAllowedError : Error, IEquatable<Error>
Inheritance
MethodNotAllowedError
Implements
Inherited Members
Extension Methods

Examples

Error.MethodNotAllowed("DELETE is not supported on this resource.", ["GET", "PUT"])

Remarks

Per RFC 9110 §15.5.6, a 405 response MUST include an Allow header listing the methods the target resource currently supports. The AllowedMethods property carries this information so that Trellis response mappers can emit the required header automatically.

Constructors

MethodNotAllowedError(string, IReadOnlyList<string>, string, string?)

Initializes a new instance of the MethodNotAllowedError class.

public MethodNotAllowedError(string detail, IReadOnlyList<string> allowedMethods, string code, string? instance = null)

Parameters

detail string

Description of why the method is not allowed.

allowedMethods IReadOnlyList<string>

The HTTP methods the resource supports.

code string

The error code identifying this type of error.

instance string

Optional identifier for the resource.

Properties

AllowedMethods

Gets the HTTP methods that the target resource currently supports. This is emitted as the Allow response header per RFC 9110 §15.5.6.

public IReadOnlyList<string> AllowedMethods { get; }

Property Value

IReadOnlyList<string>