我有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 /雇主时,没关系。 我希望/雇主和/ ru /雇主链接指向一页。 为什么会这样?我该如何解决这个问题?
答案 0 :(得分:1)
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" }
);
}
}