ASP .Net カスタム ルートが機能しない。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//default route
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "LogOn", id = UrlParameter.Optional } // Parameter defaults
);
//custom route
routes.MapRoute(
"Admin",
"Admin/{addressID}",// controller name with parameter value only(exclude parameter name)
new { controller = "Admin", action = "address" }
new { addressID = @"\d+" }
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
public ActionResult address(int addressID = 0)
{
//code and redirection
}
ここで、可能であればURLからすべてを非表示にしたい...可能であればアクション名とパラメーター名と値を非表示にしたい...これを行う可能な方法を提案してください
このような URL が必要です (優先順位に基づいて)
1.http: //localhost:abcd/Admin
または 2.http: //localhost:abcd/Admin/address
または 3.http: //localhost:abcd/Admin/1
または 4.http: //localhost:abcd/Admin/address/1