[Route("api/[controller]")] [ApiController] public class ValuesController : ControllerBase { // GET api/values [HttpGet] public ActionResult> Get() { return new string[] { "value1", "value2" }; } }
[Route("api/[controller]")] [ApiController] public class ValuesController : ControllerBase { // GET api/values/5 [HttpGet("{id}")] public ActionResultThis code defines a GET endpoint at "/api/values/{id}" that returns a string with the value "value". The {id} parameter is passed in the URL and is used to determine which value to return. Overall, the ValuesController is a simple but useful class for handling HTTP requests and returning data, and is commonly used in ASP.NET Core applications for testing and learning purposes.Get(int id) { return "value"; } }