【发布时间】:2011-08-13 16:25:48
【问题描述】:
我在当前项目中使用 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 不支持自定义约束
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 t4mvc