When I create a new controller in the API project, it generates a controller class with [ApiController]
attribute, like this:
[ApiController]
public class TestController : ControllerBase
{
//implementation
}
I've seen a few webapi projects where usage of this attribute is omitted.
Microsoft documentation here says:
Indicates that a type and all derived types are used to serve HTTP API
responses. The presence of this attribute can be used to target
conventions, filters and other behaviors based on the purpose of the
controller.
But still, I don't get the idea.
Can someone explain what is the purpose of this attribute with the real-life example?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…