MVC视图与控制器分离简单描述

一,控制器

CheckIndexAreaRegistration.cs

public class CheckIndexAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "CheckIndex";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "CheckIndex_default",
                "CheckIndex/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional },
            new string[] { typeof(CheckIndexAreaRegistration).Namespace } //增加此行,不然会出现controller命名重复的exception
            );
        }
    }

ShowAllController.cs

 public class ShowAllController : BaseController
    {
        [SkipRole]
        public ActionResult Index()
        {
            return View();
        }
    }

二,视图

原文地址:https://www.cnblogs.com/Aamir-Ye/p/4611968.html