在下面的API控制器中,如果在API上调用POST或PUT,如何返回405 Method Not allowed。目前它返回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(); } }
本文将讨论这个问题: https://github.com/aspnet/Mvc/issues/388