我這個在每個「使用條款」頁面的多種翻譯的頂部:@ Url.Action越來越長= 2附加
<li><a href="@Url.Action("Index", "Terms")">English</a></li>
<li><a href="@Url.Action("Index", "Terms", "de")">Deutsch</a></li>
<li><a href="@Url.Action("Index", "Terms", "fr")">Français</a></li>
<li><a href="@Url.Action("Index", "Terms", "it")">Italiano</a></li>
<li><a href="@Url.Action("Index", "Terms", "nl")">Nederlands</a></li>
<li><a href="@Url.Action("Index", "Terms", "hu")">Maygar</a></li>
<li><a href="@Url.Action("Index", "Terms", "es")">Español</a></li>
<li><a href="@Url.Action("Index", "Terms", "zh")">簡體中文</a></li>
<li><a href="@Url.Action("Index", "Terms", "pt-pt")">European Português</a></li>
<li><a href="@Url.Action("Index", "Terms", "pt")">Português</a></li>
這是應該處理的點擊動作:
public class TermsController : Controller
{
public ActionResult Index(string id)
{
switch (id)
{
case "de":
return View("de");
case "fr":
return View("fr");
case "it":
return View("it");
case "nl":
return View("nl");
case "hu":
return View("hu");
case "es":
return View("es");
case "zh":
return View("zh");
case "pt":
return View("pt");
case "pt-pt":
return View("pt-pt");
default:
return View();
}
}
,這些都是我的路線:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Terms",
"{controller}/{id}",
new { controller = "Terms", action = "Index" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
routes.MapRoute(
"ThankYou",
"{controller}/{action}/{email}/{id}"
);
}
從主(即英文)條款頁,第一個(即英文)鏈接看起來心病rect:
http://localhost:65391/Terms/
爲什麼其他(即外國)生成的URL看起來像這樣?
http://localhost:65391/Terms/?Length=2
而且,奇怪的是,如果我手動輸入
http://localhost:65391/Terms/de
例如,並轉到條款頁面,在德國,那麼第一個超鏈接(即回英文條款頁)外觀像這樣:
http://localhost:65391/Terms/de
去這裏看看實際的網站:
http://inrix.com/traffic/terms
僅使用一個標籤,使你的問題很難發現。您應該至少使用MVC vesion標記標記它。像asp.net-mvc-3或asp.net-mvc-4等。 – nemesv