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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.