Delen via


InputFormatterExceptionPolicy Enum

Definition

Defines the set of policies that determine how the model binding system interprets exceptions thrown by an IInputFormatter.

public enum class InputFormatterExceptionPolicy
public enum InputFormatterExceptionPolicy
type InputFormatterExceptionPolicy = 
Public Enum InputFormatterExceptionPolicy
Inheritance
InputFormatterExceptionPolicy

Fields

Name Value Description
AllExceptions 0

This value indicates that all exceptions thrown by an IInputFormatter will be treated as model state errors.

MalformedInputExceptions 1

This value indicates that only InputFormatterException and subclasses will be treated as model state errors. All other exceptions types will be re-thrown and can be handled by a higher level exception handler, such as exception-handling middleware.

Remarks

An IInputFormatter could throw an exception for several reasons, including:

  • malformed input
  • client disconnect or other I/O problem
  • application configuration problems such as TypeLoadException

The policy associated with AllExceptions treats all such categories of problems as model state errors, and usually will be reported to the client as an HTTP 400. This was the only policy supported by model binding in ASP.NET Core MVC 1.0, 1.1, and 2.0 and is still the default for historical reasons.

The policy associated with MalformedInputExceptions treats only InputFormatterException and its subclasses as model state errors. This means that exceptions that are not related to the content of the HTTP request (such as a disconnect) will be re-thrown, which by default would cause an HTTP 500 response, unless there is exception-handling middleware enabled.

Applies to