我在当前项目中使用 t4mvc 并尝试使用包含的路由助手但是当我尝试使用如下自定义约束时
routes.MapRoute(
"def_filtered_reports_route",
"reports/{samplePoint}/{fromDate}/{toDate}",
MVC.Report.Results(null, null, null),
new
{
samplePoint = new SamplePointExistsConstraint(),
fromDate = new DateTimeConstraint(),
toDate = new DateTimeConstraint()
}
);
它抛出一个ArgumentException
陈述An item with the same key has already been added.
如果我这样写
routes.MapRoute(
"def_filtered_reports_route",
"reports/{samplePoint}/{fromDate}/{toDate}",
MVC.Report.Results(null, null, null) );
或者像这样
routes.MapRoute(
"def_filtered_reports_route",
"reports/{samplePoint}/{fromDate}/{toDate}",
new
{
controller = "Report",
action = "Results",
fromDate = "",
toDate = "",
samplePoint = ""
},
new
{
fromDate = new DateTimeConstraint(),
toDate = new DateTimeConstraint(),
samplePoint = new SamplePointExistsConstraint()
});
它工作正常。
有什么我遗漏的东西还是 t4mvc 不支持自定义约束