Search code examples
.netasp.net-coreasp.net-apicontroller

What does "[controller]" mean?


For example, the route from the MSDN docs:

[Produces(MediaTypeNames.Application.Json)]
[Route("[controller]")]
public class PetsController : MyControllerBase

What does "[controller]" mean? I cannot find the definition in the MSDN docs, so please send me the docs if you do know where they are or are better at googling than I am.


Solution

  • From this reference,

    [controller] is a token and it will be replaced with the value of the controller name from the action where route is defined.

    So in this case, it indicates route /Pets/....