Skip to content

Instantly share code, notes, and snippets.

@evgomes
Created January 25, 2019 11:58
Show Gist options
  • Save evgomes/062a4f9d0e7475fc4f22d66f882982ca to your computer and use it in GitHub Desktop.
Save evgomes/062a4f9d0e7475fc4f22d66f882982ca to your computer and use it in GitHub Desktop.
Default Values.cs class from ASP.NET Core 2.2
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment