Reputation: 1685
In the below API controller , How to return 405 Method Not allowed if POST or PUT is called on the API. Currently it is returning 404 not found .
[HttpGet]
public ActionResult<IEnumerable<Customer>> Get()
{
string query = "select* from Customers;";
try
{
List<Customer> collection = GetCustomers(query);
return Ok(collection);
}
catch (System.Exception)
{
return BadRequest();
}
}
Upvotes: 4
Views: 11313
Reputation: 3234
This issue is discussed in this thread: https://github.com/aspnet/Mvc/issues/388
Upvotes: 3