zoukankan      html  css  js  c++  java
  • ASP.NET MVC 4 笔记

    1.   MVC2MV3MC4 的区别

    1)   MVC2

    1.   View 文件以*.aspx结尾,为原始html页面内容。

    2.   View 代码以<%代码结束%>

     

    2)   MVC3

    1.   View 文件以*.cshtml结尾,为cshtml页面内容。

    2.   View 代码以@开始,例如:@Html.GetType()

     

    3)   MVC4

    1.   View 文件以*.cshtml结尾,为cshtml页面内容(MVC3略有区别)

    2.   View 代码以@开始,例如:@Html.GetType()

    3.   多了一个App_Start 文件夹和 packages.config 文件。

    4.   其中:App_Start 文件夹中包含四个配置文件:

    1)   BundleConfig.cs

    2)   FilterConfig.cs

    3)   RouteConfig.cs

    4)   WebApiConfig.cs

     

    2.   Action 可返回类型

    1)   View()

    Ø  描述:创建一个将视图呈现给响应的 System.Web.Mvc.ViewResult 对象。

    Ø  重载方法:

    protected internal ViewResult View();

    protected internal ViewResult View(IView view);

    protected internal ViewResult View(object model);

    protected internal ViewResult View(string viewName);

    protected internal virtual ViewResult View(IView view, object model);

    protected internal ViewResult View(string viewName, object model);

    protected internal ViewResult View(string viewName, string masterName);

    protected internal virtual ViewResult View(string viewName, string masterName, object model);

     

    2)   Content(string content) 方法

    Ø  描述:使用字符串创建一个内容结果对象。

    Ø  参数:

    content:要写入到响应的内容。

    Ø  返回结果:内容结果实例。

     

    3)   RedirectToAction(string actionName, string controllerName) 方法

    Ø  描述:使用操作名称和控制器名称重定向到指定的操作。

    Ø  参数:

    actionName:操作方法的名称。

    controllerName:控制器的名称。

    Ø  返回结果:重定向结果对象。

     

  • 相关阅读:
    使用replaceAll替换“/”为“/”
    如何在Lucene里面进行数字范围搜索 (Numeric Range Query)
    Java中的参数传递
    安装配置WordPress 3.0的多站点功能
    Apache Hadoop 项目介绍
    Java中的Set操作
    使用Desktop API in Java SE 6打开文件或者网页
    Java集合(转帖)
    数据结构牛客网习题纠错130
    PAT 1045 Favorite Color Stripe[dp][难]
  • 原文地址:https://www.cnblogs.com/abeam/p/7873063.html
Copyright © 2011-2022 走看看