您的位置:首页 > 其它

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

2015-06-30 22:33 267 查看
一,控制器



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


二,视图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: