Why this matters
`ControllerBase` is the proper base class for API controllers, avoiding unnecessary dependencies on view-related functionality.
Verify that API controllers inherit from `ControllerBase` instead of `Controller` unless views are explicitly required.
`ControllerBase` is the proper base class for API controllers, avoiding unnecessary dependencies on view-related functionality.
Side-by-side examples engineers can pattern-match during review.
[ApiController]
public class MyController : Controller // Noncompliant: Inherit from ControllerBase instead of Controller.
// ^^^^^^^^^^
{
// ..
}[ApiController]
public class MyController : ControllerBase
{
// ..
}[ApiController]
public class MyController : Controller // Noncompliant: Inherit from ControllerBase instead of Controller.
// ^^^^^^^^^^
{
// ..
}[ApiController]
public class MyController : ControllerBase
{
// ..
}From the same buckets as this rule.