代码之家  ›  专栏  ›  技术社区  ›  Test12345

不允许从Asp返回405方法。Net核心Webapi

  •  0
  • Test12345  · 技术社区  · 7 年前

    在下面的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();
                }
            }
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   ozanmut    7 年前

    本文将讨论这个问题: https://github.com/aspnet/Mvc/issues/388

    推荐文章