0
我學習的課程描述瞭如何使用兩種或多種語言創建網站,
和本課的第一步 - 我需要在我的項目中添加以下代碼網站上的兩種語言asp.net mvc 4
context.MapRoute(
name: "lang",
url: "{lang}/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
constraints : new { lang = @"ru|en" },
namespaces: new[] { "LessonProject.Areas.Default.Controllers" }
);
context.MapRoute(
name : "default",
url : "{controller}/{action}/{id}",
defaults : new { controller = "Home", action = "Index", id = UrlParameter.Optional, lang = "ru" },
namespaces : new [] { "LessonProject.Areas.Default.Controllers" }
);
文件DefaultAreaRegistration (/Areas/Default/DefaultAreaRegistration.cs)
但我沒有在我的項目文件。
我不明白我需要創建一個新的文件夾區域和一個新的文件DefaultAreaRegistration.cs或者我需要改變RouteConfig.cs文件,其中包含
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
?
而在Global.asax中有下面的代碼
AreaRegistration.RegisterAllAreas();
什麼是我需要改變的部分?