405 method not allowed Web API

前端 未结 21 1587
栀梦
栀梦 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:56

    I had the same exception. My problem was that I had used:

    using System.Web.Mvc; // Wrong namespace for HttpGet attribute !!!!!!!!!
    [HttpGet]
    public string Blah()
    {
        return "blah";
    }
    

    SHOULD BE

    using System.Web.Http; // Correct namespace for HttpGet attribute !!!!!!!!!
    [HttpGet]
    public string Blah()
    {
        return "blah";
    }
    

提交回复
热议问题