【问题标题】:WebApi "Multiple actions were found that match that request"WebApi“找到与该请求匹配的多个操作”
【发布时间】:2013-04-04 14:27:57
【问题描述】:

还有一个问题,但我找不到任何其他问题的答案。

我的路线设置为:

public class ContentRoutes
{
    public static void Map(RouteCollection _routes)
    {
        _routes.MapHttpRoute(
            name: "GetThumbnail",
            routeTemplate: "api/content/thumbnail/{_id}",
            defaults: new { controller = "Content", id = "GetThumbnail" }
        );

        _routes.MapHttpRoute(
            name: "GetFile",
            routeTemplate: "api/content/file/{_id}",
            defaults: new { controller = "Content", id = "GetFile" }
        );
    }
}

我试图映射到我的控制器方法,这些方法声明为:

[AcceptVerbs("GET")]
public HttpResponseMessage GetThumbnail(int _id)

[AcceptVerbs("GET")]
public HttpResponseMessage GetFile(int _id)

当尝试访问其中任何一个时,我收到问题标题中显示的错误。我一定遗漏了一些明显的东西,但我不能把手指放在上面。有什么想法吗?

【问题讨论】:

  • 我觉得应该像defaults: new { controller = "Content", action = "GetThumbnail" }action =,不是id =
  • 天哪!我怎么没看到那个错字......再见我浪费的时间

标签: c# asp.net-web-api asp.net-web-api-routing


【解决方案1】:

我认为应该像defaults: new { controller = "Content", action = "GetThumbnail" }action =, not id =

(只是作为答案发布,这样它就可以被接受,因为它满足 OP)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-08
    • 2017-10-26
    • 2016-10-18
    • 2016-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-04
    相关资源
    最近更新 更多