asp.net-web-api - 405 错误 {"Message":"The requested resource does not support http method ' 获取'。"}

标签 asp.net-web-api

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

[OperationContract]
[WebInvoke(Method = "GET")]
bool IsPaymentGatewayExitsForTenant(string tenantSlugName, string productCode);

我在本地运行并使用休息客户端测试服务

api/PaymentGatewayService/IsPaymentGatewayExitsForTenant?tenantSlugName=KPN&productCode=POSS

但是我收到以下错误在此处输入代码

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

如有任何帮助,我们将不胜感激。

最佳答案

能否请您使用“HttpGet”属性装饰您的 Controller 类方法“IsPaymentGatewayExitsForTenant

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

希望这有效

关于asp.net-web-api - 405 错误 {"Message":"The requested resource does not support http method ' 获取'。"},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19674928/

相关文章:

c# - Controller 中自定义方法的 WebApi 路由

asp.net-core - 如何在asp.net core web api的 Controller 中使用模型绑定(bind)排除属性

c# - WebApi 2 GET 在参数中有特殊字符

c# - 如何通过 Web API 中的 post 请求接收流和对象?

c# - 通过URL访问Docker卷

c# - 如何在 web api 2 中正确实现异步

asp.net-web-api - 如何使用 IdentityServer4 访问我当前的用户?

asp.net-core - 为什么没有应用api版本?

c# - Asp Web Api部署数据库连接

c# - 同时读取 FromUri 和 FromBody