ValuesController.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Microsoft.AspNetCore.Mvc;
  2. using System.Collections.Generic;
  3. // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
  4. namespace WebApi.Controllers
  5. {
  6. [Route("api/[controller]")]
  7. [ApiController]
  8. public class ValuesController : ControllerBase
  9. {
  10. // GET: api/<ValuesController>
  11. [HttpGet]
  12. public IEnumerable<string> Get()
  13. {
  14. return new string[] { "value1", "value2" };
  15. }
  16. // GET api/<ValuesController>/5
  17. [HttpGet("{id}")]
  18. public string Get(int id)
  19. {
  20. return "value";
  21. }
  22. // POST api/<ValuesController>
  23. [HttpPost]
  24. public void Post([FromBody] string value)
  25. {
  26. }
  27. // PUT api/<ValuesController>/5
  28. [HttpPut("{id}")]
  29. public void Put(int id, [FromBody] string value)
  30. {
  31. }
  32. // DELETE api/<ValuesController>/5
  33. [HttpDelete("{id}")]
  34. public void Delete(int id)
  35. {
  36. }
  37. }
  38. }