405 method not allowed Web API

前端 未结 21 1652
栀梦
栀梦 2020-11-27 18:33

This error is very common, and I tried all of the solutions and non of them worked. I have disabled WebDAV publishing in control panel and added this to my web config file:<

21条回答
  •  执笔经年
    2020-11-27 18:48

    This does not answer your specific question, but when I had the same problem I ended up here and I figured that more people might do the same.

    The problem I had was that I had indeliberately declared my Get method as static. I missed this an entire forenoon, and it caused no warnings from attributes or similar.

    Incorrect:

    public class EchoController : ApiController
    {
        public static string Get()
        {
            return string.Empty;
        }
    }
    

    Correct:

    public class EchoController : ApiController
    {
        public string Get()
        {
            return string.Empty;
        }
    }
    

提交回复
热议问题