0
我可以有URL在更多格式:與多個可變參數的URL映射
site.net/Controller/Function/AnyStringProperty
site.net/Controller/Function/AnyIntProperty
site.net/Controller/Function/AnyStringProperty/AnyIntProperty
在控制器I可以寫爲Property1和Property2任何邏輯,但它似乎是骯髒的方式。
另一種方式是寫類似 site.net/Controller/Function/AnyDefautlForStringProperty/AnyIntProperty
除了
site.net/Controller/Function/AnyIntProperty
是任何可能性怎麼辦這在routes.MapRoute函數中?或者在其他地方,然後在控制器?
routes.MapRoute(
"Controller/Function",
"Controller/Function/{AnyStringProperty}/{AnyIntProperty},
new { controller = "Controller", action = "Function", AnyStringProperty = "", AnyIntProperty = ""}
);
謝謝,我會嘗試一下,但我怕它後URL不會太酷... :-) –