zoukankan      html  css  js  c++  java
  • Asp.net mvc 3.0新特性浅析1

    (1)首先我们在新建---项目时,在mvc3.0中我们有三种选择:

      

    在新建mvc3.0项目时,如果我们选择了aspx,那么我们新建的视图文件扩展名就是.aspx。如果我们选择了Razor,那么我们新建的视图文件扩展名就是.cshtml。

    http://msdn.microsoft.com/zh-cn/ff849693.aspx中给了我们很好的关于Razor这种新视图引擎的介绍。

    (2)mvc3.0中Web.config文件中有几处变化,例如:

     <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>

    版本号的变化:由原来的System.Web.Mvc, Version=2.0.0.0变成了现在的System.Web.Mvc, Version=3.0.0.0;

    还有就是

    这是在mvc2.0中的。下面是mvc3.0中的:

     <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>

    这就是mvc3.0在Web.config文件中两处较为明显的改变啊!

    (3)我们都知道在mvc2.0及1.0更早的版本中,我们在使用ViewData时必须是:

    public ActionResult Index() {

        ViewData["Title"] = "The Title";

        ViewData["Message"] = "Hello World!";

    }

    那么在mvc3.0版本中,我们就可以用如下方法:

    public ActionResult Index() {

        ViewModel.Title = "The Title";

        ViewModel.Message = "Hello World!";

    }

    这就是mvc3.0中其中一大改变啊!

    (4)在"Add View"对话框中也有所改变。

      

    我们可以在视图引擎有两种选择啊!aspx和Razor。

    (5)Global.asax中的变化。在mvc2.0版本中Application_Start()是如下定义的:

    protected void Application_Start()

            {

                AreaRegistration.RegisterAllAreas();

                RegisterRoutes(RouteTable.Routes);

            }

    在mvc3.0版本中Application_Start()是如下定义的:

    protected void Application_Start()

            {

                AreaRegistration.RegisterAllAreas();

                RegisterGlobalFilters(GlobalFilters.Filters);

                RegisterRoutes(RouteTable.Routes);

            }

    此外如果我们想使用action filter,那么我们必须在Application_Start中添加:

    GlobalFilters.Filters.Add(new MyActionFilter());

    (6)New JsonValueProviderFactory Class变化

        如果我们想了解更多关于JsonValueProviderFactory的信息,可以在Sending JSON to an ASP.NET MVC Action Method Argument 这篇博客中获得非常详细的信息啊!

  • 相关阅读:
    Python有返回值的函数_布尔函数
    struts通配符*的使用
    实现action的三种方法
    filter
    struts常量<constant>说明
    dtd文件本地配置
    namespace
    Spring的第一个例子
    SSH新学,关于面向对象的看法
    @OneToMany---ManyToOne
  • 原文地址:https://www.cnblogs.com/wzk89/p/1853279.html
Copyright © 2011-2022 走看看