空參數我有一個應該由一個自動化的過程只會被調用路線:允許在MVC路線
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 Error 400 - Bad Request。
我有一個類似的問題,我發佈在這裏:http://stackoverflow.com/questions/4743431/need-help-canonicalizing-an-http-get-form-in-asp-net-mvc。基本上,達林是對的。只有最後一個參數可以是可選的。 – danludwig 2011-01-22 05:45:31
看到這個,http://bit.ly/dem6F5 – user960567 2012-04-08 04:46:06