码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-06-30 23:16:45      阅读:172      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!