Testing another articleTesting another articleTesting another articleTesting another articleTesting another articleTesting another articleTesting another articleTesting another article
using Microsoft.AspNetCore.Mvc;
namespace MyApp.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class SampleController : ControllerBase
{
// GET api/sample
[HttpGet]
public IActionResult Get()
{
return Ok("Hello, World!");
}
// GET api/sample/{id}
[HttpGet("{id}")]
public IActionResult Get(int id)
{
return Ok($"You requested ID: {id}");
}
// POST api/sample
[HttpPost]
public IActionResult Post([FromBody] SampleModel model)
{
if (ModelState.IsValid)
{
return CreatedAtAction(nameof(Get), new { id = model.Id }, model);
}
return BadRequest(ModelState);
}
}
public class SampleModel
{
public int Id { get; set; }
public string Name { get; set; }
}
}
Top comments (2)
Congrats for you first post and we hope to see your content soon. Also, we ask for the right use of the tags, they are made for users interested in things like NodeJS, Azure, Linux... find relevant posts of the subject they like.
haha, I am sorry, this as just testing, but I am sure it comes up something soon <3