升级到mvc4 rc后,在控制器上发现了多个操作

时间:2012-07-03 19:02:49

标签: asp.net-mvc asp.net-web-api

我们一直在使用mvc webapi beta并正在尝试升级到rc。

我们有以下路由(唯一的约束是验证{id}是一个整数):

"Api Verb with SubAction"   api/{controller}/{id}/{action}
"Api Verb with Id"          api/{controller}/{id}
"Api Verb without Id"       api/{controller}
"Api Action with Id"        api/{controller}/{action}/{id}
"Api Action without Id"     api/{controller}/{action}

以下控制器操作

public IList<PaymentMethodViewModel> GetList()
{}

public HttpResponseMessage Get(Guid id)
{}

[ActionName("Details")]
public IList<RecurrenceModel> GetDetails(Guid id)
{}

api / mycontroller,api / mycontroller / 1,api / mycontroller / 1 /详细信息都在测试版中正确返回。但是,在升级到MVC4 RC api / mycontroller / 1后,api / mycontroller / 1 / details返回“发现符合请求的多个操作:”

1 个答案:

答案 0 :(得分:0)

是的,我有类似的问题,但未能找到正确的理由。这显然是由于路由实现的变化,但它的代码非常庞大,我没有时间来讨论它。

鉴于它将继续以这种速度发展,最好只依赖于内置路由机制来实现默认的{controller}/{id}样式路由,而AttributeRouting依赖于其他任何东西。

相关问题