0

I'm learning asp.net core to create a rest API and the docs at msdn suggests (from my interpretation of the text) that you could have a controller class (ie. a class that inherits from ControllerBase or Controller) that could not have the [ApiController] attribute.

Is that right? If so in what circumstances a controller don't need the attribute?

underthevoid
  • 513
  • 1
  • 6
  • 17

1 Answers1

1

ApiController provides some specific functions, you don't need to use these or not add it, it depends on your own needs.

The [ApiController] attribute can be applied to a controller class to enable the following opinionated, API-specific behaviors:

1.Attribute routing requirement

2.Automatic HTTP 400 responses

3.Binding source parameter inference

4.Multipart/form-data request inference

These features require a compatibility version of 2.1 or later.

Tupac
  • 2,590
  • 2
  • 6
  • 19