MVC Areas的使用

在网上查了一些资料 关于这个写的都很简单,没得实际应用。

参考了一下别人的代码,写篇博文记录一下。

首先目录结构:

然后主要是 BaseAreaRegistration 文件内容

    public class BaseAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Base";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Base_default",
                "Base/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }

Global.asax 中需要添加一句

            AreaRegistration.RegisterAllAreas();
原文地址:https://www.cnblogs.com/Aaxuan/p/11274150.html