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();
什么是我需要改变的部分?