【发布时间】:2010-03-31 12:45:50
【问题描述】:
谁能给我解释一件事。
我的控制器中有两种方法:
public ActionResult AddPredefinedTicket(int customerId) {...}
和
public ActionResult AddPredefinedTicket(int customerId, TicketTypes type, string additionalJsonParameters) {...} (here TicketTypes is enum)
我正在尝试使用类似 URL 的方式拨打电话
@987654321@
由于某种原因,我遇到了异常:
The current request for action 'AddPredefinedTicket' on controller type 'TicketController' is ambiguous between the following action methods:
System.Web.Mvc.ActionResult AddPredefinedTicket(Int32) on type CallCenter.CustomerService.Controllers.TicketController
System.Web.Mvc.ActionResult AddPredefinedTicket(Int32, CallCenter.CustomerService.Data.Models.TicketTypes, System.String) on type CallCenter.CustomerService.Controllers.TicketController
但是,我不明白为什么 MVC 认为请求是模棱两可的。 正如您从我的 URL 调用中看到的那样,我既没有传递“type”也没有传递“additionalJsonParameters”参数。 我知道,additionalJsonParameters 是字符串,所以可以为空。
但是action也有“type”参数,即枚举,不能为null。
在我看来,MVC 应该使用 first action,但它没有。
你能解释一下为什么吗?
【问题讨论】:
标签: asp.net-mvc