zoukankan      html  css  js  c++  java
  • 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>

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

  • 相关阅读:
    使用Microsoft.DirectX和Microsoft.DirectX.Sound进行录音时遇到的异常
    一个奇怪的TextChanged事件
    正则表达式
    lambda详解
    AOP统一处理请求
    SpringBoot表单参数验证
    208道Java常见面试题
    Java100道基础面试题
    Java多线程面试题
    Java编码规范
  • 原文地址:https://www.cnblogs.com/qqloving/p/2010909.html
Copyright © 2011-2022 走看看