[英]default route parameters in asp.net mvc RouteConfig
我有RouteConfig
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "EmployerDefault",
url: "{lang}/employer",
defaults: new { lang = "ru", controller = "Employer", action = "Index" }
);
}
}
和控制器
public class EmployerController : Controller
{
public ActionResult Index()
{
return View("EmployerMaster");
}
}
当我转到链接/ employer时 ,我得到HTTP 404.0-Not Found,但是当我尝试获取/ ru / employer时就可以了。 我希望/ employer和/ ru / employer链接引用一页。 为什么会发生? 我该如何解决?
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "EmployerDefault",
url: "/employer",
defaults: new { lang = "ru", controller = "Employer", action = "Index" }
routes.MapRoute(
name: "EmployerWithLang",
url: "{lang}/employer",
defaults: new { lang = "ru", controller = "Employer", action = "Index" }
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.