ASP.NET MVC 3 Preview1发布

下载地址:http://go.microsoft.com/fwlink/?LinkID=157073

新功能

1.Razor引擎

在新建时可以选择引擎

image

并且可以与ASP.NET MVC 2同时存在

新建View时可以选择引擎

image

虽然现在还没有VS支持的HighLight和智能感知支持不过我还是很喜欢这个新的模板引擎的

image

据说相应的VS支持会在晚些时候发布

Razor的语法可以在这里学习到:http://aspnet.codeplex.com/wikipage?title=WebPages&referringTitle=Home

2.全局Filter

可以让开发人员在Global.asax中添加作用于所有Controller的Filter

image

这样我们就不用每个类都去写Filter或在几个基类写Filter了

3.Dynamic ViewModel的支持

原来我们使用的ViewData

image

我们可以改用Dynamic的ViewModel属性

image

注意要引用Microsoft.CSharp.dll

4.新增加了几个ActionResult

HttpNotFound

当某个数据从数据库中查找不到时,应该返回404,继承于HttpStatusCodeResult
            if (g == null)
                return HttpNotFound("group not found");

HttpStatusCodeResult

用于返回其它的状态,如304,500,501

5.另外还有支持依赖流入、DataAnnotations验证的改进,可以通过ScottGu的博客了解

ScottGu的博客(http://weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview-1.aspx

依赖注入相关文章

  • ASP.NET MVC 3 Service Location: Introduction (Part 1)
  • ASP.NET MVC 3 Service Location: Controllers (Part 2)
  • ASP.NET MVC 3 Service Location: Views (Part 3)
  • ASP.NET MVC 3 Service Location: Filters (Part 4)
  • 原文地址:https://www.cnblogs.com/chsword/p/aspnetmvc3pv1publish.html