ルートを定義しました:
routes.MapRoute(
name: "SearchRoute",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Search",
action = "Index", id = UrlParameter.Optional }
索引方法:
public ActionResult Index(int? id, SearchViewModel model)
- http://xxx.xxx.xxx.xxx/Searchを参照すると、SearchController で Index アクションが実行されました。
- http://xxx.xxx.xxx.xxx/Search/1にアクセスすると、404 エラーが発生します。
- http://xxx.xxx.xxx.xxx/Search/Index/1をブラウズします。
上記の 2 で作業し、入力する必要はありません/Index/1
。どのように?