MVC 4アプリケーションでは、ルーティングを定義するときに、デフォルトのパラメーターのリストを提供できます。オプションのパラメータにどのような値を指定する必要がありますか:UrlParameter.Optional
または空の文字列?
例:
routes.MapRoute("simple", "{controller}/{action}/{id}",
new {controller = "Home", action = "Index", id = UrlParameter.Optional});
routes.MapRoute("simple", "{controller}/{action}/{id}",
new {controller = "Home", action = "Index", id = ""});
上記の例id = ""
との間に違いはありますか?id = UrlParameter.Optional
一部のコントローラーアクションはid
(タイプのstring
)を使用し、一部はパラメーターなしになることに注意してください。