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();
            }
        }
This issue is discussed in this thread: https://github.com/aspnet/Mvc/issues/388
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