1,turorial ,根据链接教程新建一个MVC项目

http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4

First Page:

2,M-V-C:

Models: 存放数据模型(Model Data),验证接收的数据(Validation Logic)

Views:  用户看到的HTML页面 (dynamically genetate HTML Page)

Controls:处理用户请求,从Models中检索数据以后,指定View页面输出(specify View templates)到浏览器

Add a new controller:

3, 了解MVC运行机制

   MVC 根据不同的URL请求,MVC框架会实例化Controller方法,然后调用相应controller class 中的相应的action methods .默认的调用路径是:/[Controller]/[ActionName]/[Parameters]

http://localhost:9898/helloWorld/index /helloworld/index

http://localhost:9898/helloWorld/welcome /helloworld/welcome

上面的路径,MVC的路由机制会从helloworldController控制器中找到index方法和welcome方法,直接显示HTML页面。路径中没有Parameters

更新Controller中的Welcome方法如下

public string Welcome(string name, int numTimes = 1) {

return HttpUtility.HtmlEncode("Hello " + name + ", NumTimes is: " + numTimes);}

浏览器地址手动更新为:http://localhost:9898/helloWorld/Welcome?name=Spring&numtimes=8

参数即被传递到页面中:

参考:

http://www.asp.net/mvc/tutorials/mvc-4

http://pluralsight.com/training/Player?author=scott-allen&name=mvc4-building-m1-intro&mode=live&clip=0&course=mvc4-building (mvc4 video)

ASP.NET MVC 学习1、新增Controller,了解MVC运行机制的更多相关文章

  1. ASP.NET MVC 学习笔记-7.自定义配置信息 ASP.NET MVC 学习笔记-6.异步控制器 ASP.NET MVC 学习笔记-5.Controller与View的数据传递 ASP.NET MVC 学习笔记-4.ASP.NET MVC中Ajax的应用 ASP.NET MVC 学习笔记-3.面向对象设计原则

    ASP.NET MVC 学习笔记-7.自定义配置信息   ASP.NET程序中的web.config文件中,在appSettings这个配置节中能够保存一些配置,比如, 1 <appSettin ...

  2. Spring MVC 学习总结(一)——MVC概要与环境配置 转载自【张果】博客

    Spring MVC 学习总结(一)--MVC概要与环境配置   目录 一.MVC概要 二.Spring MVC介绍 三.第一个Spring MVC 项目:Hello World 3.1.通过Mave ...

  3. .NET MVC 学习笔记(三)— MVC 数据显示

    . NET MVC 学习笔记(三)—— MVC 数据显示 在目前做的项目中,用的最多的数据展示控件就是table展示(说不是的请走开,不是一路人),以下详细阐述下table的使用方法. 先看效果: 上 ...

  4. ASP.NET MVC 学习笔记-5.Controller与View的数据传递

    ViewData属性 ViewData属性是System.Web.Mvc.ControllerBase中的一个属性,它相当于一个数据字典.Controller中向该字典写入数据,ViewData[“K ...

  5. Spring MVC 学习总结(一)——MVC概要与环境配置

    一.MVC概要 MVC是模型(Model).视图(View).控制器(Controller)的简写,是一种软件设计规范,用一种将业务逻辑.数据.显示分离的方法组织代码,MVC主要作用是降低了视图与业务 ...

  6. Spring MVC 学习总结(一)——MVC概要与环境配置(IDea与Eclipse示例)

    一.MVC概要 MVC是模型(Model).视图(View).控制器(Controller)的简写,是一种软件设计规范,用一种将业务逻辑.数据.显示分离的方法组织代码,MVC主要作用是降低了视图与业务 ...

  7. 【Spark 深入学习 04】再说Spark底层运行机制

    本节内容 · spark底层执行机制 · 细说RDD构建过程 · Job Stage的划分算法 · Task最佳计算位置算法 一.spark底层执行机制 对于Spark底层的运行原理,找到了一副很好的 ...

  8. ASP.NET MVC 学习4、Controller中添加SearchIndex页面,实现简单的查询功能

    参考:http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/examining-the-edit-method ...

  9. ASP.NET MVC 学习3、Controller左手从Model获取数据,右手传递到View页面

    参考:http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/accessing-your-models-dat ...

  10. ASP.NET MVC 学习8、Controller中的Detail和Delete方法

    参考:http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/examining-the-details-and ...

随机推荐

  1. android 开发 获取各种intent (图片、apk文件、excel、pdf等文件)

    public static Intent openFile(String filePath){ File file = new File(filePath); if(!file.exists()) r ...

  2. JSP访问Spring中的bean

    JSP访问Spring中的bean <%@page import="com.sai.comment.po.TSdComment"%> <%@page import ...

  3. Hibernate各种主键生成策略与配置详解【附1--<generator class="foreign">】

    1.assigned 主键由外部程序负责生成,在 save() 之前必须指定一个.Hibernate不负责维护主键生成.与Hibernate和底层数据库都无关,可以跨数据库.在存储对象前,必须要使用主 ...

  4. We Recommend a Singular Value Decomposition

    We Recommend a Singular Value Decomposition Introduction The topic of this article, the singular val ...

  5. threaded模式下,比prefork模式要省资源

    关于nginx + fastcgi + django 2009-03-10 17:14:43 分类: 系统运维 最近用django开发了一套广告投放系统,这套系统其实是一套网络广告联盟系统,包括广告的 ...

  6. POJ1013Counterfeit Dollar

    这个题主要是判断硬币真假,可能轻可能重,称三次,要输出哪枚是假币,还要输出是重的还是轻的,所以最主要的是标记变量 #include<cstdio> #include<cstring& ...

  7. Test Markdown Editor

    Last night, I just saw a cute blogger's homepage. Then I want to write something. But anyway, I use ...

  8. Thread的第一天学习

    1.实现线程的方法: 1)extend Thread 2)implements Runnable 2.下面代码执行哪个run方法: new Thread( new Runnable(){ public ...

  9. GDB笔记

    GDB是在Linux命令行下对C/C++的程序进行调试常用的一个命令,现将平时记录在本子上的笔记整理如下: 一.断点 断点类型有breakpoints, watchpoints, catchpoint ...

  10. Mybatis全部查询遇到的返回类型的小问题

    在学习Mybatis3过程中遇到一个小问题,觉得需要注意就把它写下来了 在查询所有数据的时候方法是这样的 public List<User> findAll(){ ..... } 在它的u ...