Asp.net web api 405错误{“消息”:“请求的资源不支持http方法';获取';”

Asp.net web api 405错误{“消息”:“请求的资源不支持http方法';获取';”,asp.net-web-api,Asp.net Web Api,我在我的界面中使用以下代码,并使用webapi服务 [OperationContract] [WebInvoke(Method = "GET")] bool IsPaymentGatewayExitsForTenant(string tenantSlugName, string productCode); 我正在本地运行并使用rest客户端测试服务 api/PaymentGatewayService/IsPaymentGatewayExitsForTenant?tenantSlugName=K

我在我的界面中使用以下代码,并使用webapi服务

[OperationContract]
[WebInvoke(Method = "GET")]
bool IsPaymentGatewayExitsForTenant(string tenantSlugName, string productCode);
我正在本地运行并使用rest客户端测试服务

api/PaymentGatewayService/IsPaymentGatewayExitsForTenant?tenantSlugName=KPN&productCode=POSS
但是我得到了以下错误
在这里输入code

{"Message":"The requested resource does not support http method 'GET'."} `enter code here`

欢迎提供任何帮助。

请将控制器类方法“
IsPaymentGatewayExitsForTenant
”修饰为“
HttpGet
”属性

[System.Web.Http.HttpGet]
bool IsPaymentGatewayExitsForTenant(string tenantSlugName, string productCode)
{
   // your code goes here
}

希望这能起作用

控制器的基类是什么?请再显示一些代码。@markusApiController@madhu在StackOverflow上,如果有人建议答案,并且答案解决了您遇到的问题,请单击建议答案左侧的灰色复选标记。更多信息,请看这里。