The requested resource does not support HTTP method 'GET'

前端 未结 5 670
你的背包
你的背包 2020-12-02 15:21

My route is correctly configured, and my methods have the decorated tag. I still get \"The requested resource does not support HTTP method \'GET\'\" message?



        
5条回答
  •  感动是毒
    2020-12-02 15:45

    Please use the attributes from the System.Web.Http namespace on your WebAPI actions:

        [System.Web.Http.AcceptVerbs("GET", "POST")]
        [System.Web.Http.HttpGet]
        public string Auth(string username, string password)
        {...}
    

    The reason why it doesn't work is because you were using the attributes that are from the MVC namespace System.Web.Mvc. The classes in the System.Web.Http namespace are for WebAPI.

提交回复
热议问题