MVC Controller is still our recommended structure. It is universal, flexible, stable, but currently does not support AOT.
Controllers should handle the following responsibilities:
Manager to handle business logic.Controllers should NOT directly:
DbContext to access the database.In essence, controllers should do only what they're designed for. Anything else should not be implemented directly in the controller, as controllers already handle many concerns in complex scenarios.
Note
Controller APIs should express only API contract-related content. Business implementation should be delegated to Manager, maintaining clean and maintainable code.
This is a recommended practice, not a hard requirement.
ActionResult<T> directly; do not use custom wrapper classes.Problem() in controllers to return error responses.BusinessException in Manager to throw business errors.Both Problem and BusinessException support custom error codes.
ApiResponse<T>Note
Using standard HTTP status codes maximizes compatibility with various clients and avoids unnecessary complications. This does not conflict with custom business status codes, which can be implemented through Problem and BusinessException, ultimately returning an ErrorResult structure.