我有一条路线,我想满足3个条件。这些条件是:
报告1 = ClientID,SupplierID,ReviewPeriodID
报告2 = ClientID,SupplierID
报告3 = ClientID,ReviewPeriodID。
我目前使用的路线是:
routes.MapRoute(
name: "SupplierReportBoth",
url: "{client}/Reports/SupplierReportSelection/{ClientID}/{SupplierID}/{ReviewPeriodID}",
defaults: new { client = "APL", controller = "Reports", action = "SupplierReportSelection", ClientID = UrlParameter.Optional, SupplierID = "", ReviewPeriodID = UrlParameter.Optional }
);
这满足3种报告类型中的2种。它满足报告类型1和报告类型2.但是,当我到达第三个报告类型时,路由失败并且它移动到更通用的路由并且它看起来不是很好。
问题在于路线中参数的定位。因为SupplierID是第一个,但我使用的是ReviewPeriodID,它无法识别正在传递的ID。
有没有办法解决这个问题?
对不起,这很难解释
答案 0 :(得分:0)
Your routing parameters for 2 and 3 are the same ie. int/int. The router cannot distinguish between them. You could just have one controller action and use the query string parameters to decide which report to return.