ASP.NET开源MVC框架Vici MVC(二)Controllers和templates基础

ASP.NET开源MVC框架Vici MVC 最大的特点是支持ASP.NET2.0  iis不需要额外的设置

官方实例下载地址http://viciproject.com/wiki/Projects/Mvc/UserGuide/Routing

 

Vici的Controllers和templates和ASP.NET mvc还要点不太一样

首先是Controllers

11

index 的内容如下

 public class index : Controller
    {

        public void Run()
        {
            ViewData["msg"] = "helloword";
        }

        [View("home")]
        public void home()
        {
            ViewData["msg2"] = "helloword2";
           // ChangeLayout("");
            //RenderView("");
         

        }

    }

1注意index继承Controller

2注意index.cs 只要放在Controllers下面就行了,至于是放在Controllers/a 还是Controllers/B 没有关系 只要 类名为index且继承了Controller就行

Run() 方法为 只访问Controller时执行的 开始我以为和构造函数擦不多 后来发现不是 如果访问index/home.aspx就直接执行home()了

然后是模板

22

Vici的模板有2个限制

1文件的后缀只能是  .htm

2必须有一个模板的模板系统默认是master.htm

模板的要注意一个地方  {{@VIEW}} ,这个标记是占位的 其他模板的内容(其他模板body里的内容)会出现在这个地方

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
模板页
{{@VIEW}}
</body>
</html>

悲伤理解的不深刻就只能这样了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值