I have .net core WebApi like below. And it is working perfectly. But, when I write [HttpDelete] instead of [HttpDelete("{id}")] , then it doesn't work. What can be reason ?
My url : http://localhost:5004/api/Student/DeleteStudent/23
[ApiController]
[Route("api/[controller]/[action]")]
public class StudentController : ControllerBase
{
//[HttpDelete] ///////////////// This is not working
[HttpDelete("{id}")] /////////// This is working
public async Task<ServiceResult> DeleteStudent(int id)
{
return await studentService.DeleteStudent(id);
}
}
http://localhost:5004/api/Student/DeleteStudent?id=23). Either way, the id needs to be provided to know which record to delete