1
나는 RouteConfig에 정의 된 내 노선과 MVC4의 aplications에이 같은 확인 작업이 있습니다경로가 작동하지 않습니다
routes.MapRoute(
"LocalizedDefault", "{lang}/{homePage}",
new { controller = "Home", action = "Index", pageCode = "home" },
new {lang = @"(en|es)", homePage = @"(home|inicio)"}
);
routes.MapRoute(
"Flowers",
"{lang}/{page}",
new {controller = "Plants", action = "Flowers", pageCode = "flowers"},
new {lang = @"(en|es)", page= @"(flowers|flores)"}
);
/* ... more routes ... */
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
모든 경로 매개 변수가 있습니다 당신이 볼 수있는 내 언어 (내 비즈니스 로직)를 변경해야 할 때 문제는 URL을 http://www.mydomain.com과 같이 입력하지 않으면 내 기본 페이지를로드하지만 내 페이지 매개 변수가 없기 때문에 언어를 변경할 수 없다는 것입니다. 그러면 내 경로가 변경됩니다.
routes.MapRoute(
"Flowers",
"{lang}/{page}",
new {controller = "Plants", action = "Flowers", pageCode = "flowers"},
new {lang = @"(en|es)", page= @"(flowers|flores)"}
);
/* ... more routes ... */
routes.MapRoute(
"Default",
"{lang}/{page}",
new { controller = "Home", action = "Index", pageCode = "home" },
new {lang = @"(en|es)", page = @"(home|inicio)"}
);
이제 내 사이트가 변경됩니다. 그 언어 호출 http://www.mydomain.com하지만 다른 경로가 더 이상 작동하지 않는 경우 확인 (예 : http://www.mydomain.com/en/flowers)
내가 전체 경로 mydomain.com/home/index?lang=es를 호출하여 해당 매개 변수 – ety
을 추가 할 수 있습니까? –
아니요, 분명했습니다.이 mydomain.com/es/inicio 및 mydomain.com/en/home ....으로 잘 작동합니다. 그러나 mydomain.com도 필요합니다. – ety