Dela via


ApiBehaviorOptions.SuppressMapClientErrors Property

Definition

Gets or sets a value that determines if controllers with ApiControllerAttribute transform certain client errors.

When false, a result filter is added to API controller actions that transforms IClientErrorActionResult. Otherwise, the filter is suppressed.

By default, ClientErrorMapping is used to map IClientErrorActionResult to a ProblemDetails instance (returned as the value for ObjectResult).

To customize the output of the filter (for e.g. to return a different error type), register a custom implementation of IClientErrorFactory in the service collection.

public:
 property bool SuppressMapClientErrors { bool get(); void set(bool value); };
public bool SuppressMapClientErrors { get; set; }
member this.SuppressMapClientErrors : bool with get, set
Public Property SuppressMapClientErrors As Boolean

Property Value

The default value is false.

Remarks

This property is associated with a compatibility switch and can provide a different behavior depending on the configured compatibility version for the application. See CompatibilityVersion for guidance and examples of setting the application's compatibility version.

Configuring the desired value of the compatibility switch by calling this property's setter will take precedence over the value implied by the application's CompatibilityVersion.

If the application's compatibility version is set to Version_2_1 or lower then this setting will have the value false unless explicitly configured.

If the application's compatibility version is set to Version_2_2 or higher then this setting will have the value true unless explicitly configured.

Applies to