【发布时间】:2014-03-02 07:36:16
【问题描述】:
我已经定义了属性路由,它接受两个参数作为日期时间
[Route("{controller}/{action}/{*startDate:datetime}/{*endDate:datetime}")]
public bool OverView(DateTime startDate,DateTime endDate)
{
var dt = startDate.ToString("yyyy-MM-dd");
return true;
}
但不确定,这怎么可能。属性路由适用于单个参数,但不确定它如何适用于 2 个参数。也很难知道它是如何从 url 中区分两个参数的
单个参数很好用
http://domain.com/Home/overview/2014/02/01
两个参数的 url 是什么?我尝试了下面的,但遇到了异常
http://domain.com/Home/overview/2014/02/01/2014/02/04
Exception
A catch-all parameter can only appear as the last segment of the route URL.
Parameter name: routeUrl
【问题讨论】:
标签: asp.net-mvc attributerouting