I'm using .net core 2.1 , when I created controller and inherit ApiController. but in my controller method return type HttpResponseMessage and give a error given question title here is my method
[HttpGet]
[Route("GetAll")]
[AcceptVerbs("Get", "Post")]
public HttpResponseMessage SelectCAllCustomers()
{
    try
    {
        return Request.CreateResponse<List<Customer>>(HttpStatusCode.OK, customerDetailsRepository.FindAll("SelectAllCustomers").ToList());
    }
    catch (Exception ex)
    {
        return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
    }
}
Asp.Net Core no longer uses that API.
Use the updated syntax
[Route("api/[controller]")]
public class CustomersController: Controller {
    //...
    [HttpGet("GetAll")]
    [AcceptVerbs("Get", "Post")]
    public IActionResult SelectCAllCustomers() {
        var model = customerDetailsRepository.FindAll("SelectAllCustomers").ToList();
        return Ok(model);            
    }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With