首页 > Web开发 > 详细

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

时间:2015-06-30 23:15:20      阅读:303      评论:0      收藏:0      [点我收藏+]

一,控制器

 

技术分享

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();
        }
    }

二,视图

技术分享

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

原文:http://www.cnblogs.com/Aamir-Ye/p/4611968.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!