【发布时间】:2010-12-15 06:07:50
【问题描述】:
我有一条只能由自动化进程调用的路由:
routes.MapRoute(
"Automated file processing",
"Process/{change}/{file}/{type}",
new { controller = "C", action = "Process" }
);
file 和 type 都是可选参数。理想情况下,我希望能够打电话
/Process/Created/Filename/Text (with file and type)
/Process/DirectoryListing//Text (with type only)
/Process/Created/Filename/ (with file only)
您将如何实现中间的可选参数?使用我展示的示例路线,即使我将file = "", type = "" 添加到路线中,我也会得到:
HTTP 错误 400 - 错误请求。
【问题讨论】:
-
我在这里发布了一个类似的问题:stackoverflow.com/questions/4743431/…。基本上,达林是对的。只有最后一个参数可以是可选的。
-
看这个,bit.ly/dem6F5
标签: asp.net-mvc routes string