【发布时间】:2011-03-09 08:38:15
【问题描述】:
有谁知道如何在 ASP.NET MVC3 中配置区域。
我在here 中读到了一篇关于区域的文章。
但是那篇文章不是基于 MVC3 的。
在 MVC3 中,在 Global.asax 中找到的 RouteCollection routes 中没有名为 MapRootArea 的函数
routes.MapRootArea("{controller}/{action}/{id}",
"AreasDemo",
new { controller = "Home", action = "Index", id = "" });
当我使用 MVC3 创建一个新区域时,我得到了一个继承自 AreaRegistration 的区域的类,如下所示:(这里的博客是区域名称)
public class BlogsAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Blogs";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Blogs_default",
"Blogs/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
谁能帮助我如何在 MVC3 中配置区域。任何类型的链接也会有所帮助。
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-3 asp.net-mvc-areas