ASP.net MVC 3 Improvements
• The Razor View Engine
o http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx
Some new Razor features include the following:
• @model syntax for specifying the type being passed to the view.
• @* *@ comment syntax.
• The ability to specify defaults (such as layoutpage) once for an entire site.
• The Html.Raw method for displaying text without HTML-encoding it.
• Support for sharing code among multiple views (_viewstart.cshtml or _viewstart.vbhtml files).
Razor also includes new HTML helpers, such as the following:
• Chart. Renders a chart, offering the same features as the chart control in ASP.NET 4.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=597&AspxAutoDetectCookieSupport=1
• WebGrid. Renders a data grid, complete with paging and sorting functionality.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=615
• Crypto. Uses hashing algorithms to create properly salted and hashed passwords.
http://dotnetslackers.com/articles/aspnet/Experience-ASP-NET-MVC-3-Beta-New-View-Helpers-Part2.aspx#s10-the-crypto-helper
http://www.jasypt.org/howtoencryptuserpasswords.html
• WebImage. Renders an image.
http://dotnetslackers.com/articles/aspnet/Experience-ASP-NET-MVC-3-Beta-New-View-Helpers-Part2.aspx#s10-the-crypto-helper
• WebMail. Sends an email message
http://dotnetslackers.com/articles/aspnet/Experience-ASP-NET-MVC-3-Beta-New-View-Helpers-Part2.aspx#s10-the-crypto-helper
• Support for Multiple View Engines
o The Add View dialog box in ASP.NET MVC 3 lets you choose the view engine you want to work with, and the New Project dialog box lets you specify the default view engine for a project. You can choose the Web Forms view engine (ASPX), Razor, or an open-source view engine such as Spark, NHaml, or NDjango.
• Controller Improvements
Global Action Filters
Sometimes you want to perform logic either before an action method runs or after an action method runs. To support this, ASP.NET MVC 2 provided action filters. Action filters are custom attributes that provide a declarative means to add pre-action and post-action behavior to specific controller action methods. However, in some cases you might want to specify pre-action or post-action behavior that applies to all action methods. MVC 3 lets you specify global filters by adding them to the GlobalFilters collection. For more information about global action filters, see the following resources:
• Scott Guthrie's blog on the MVC 3 Preview
• Filtering in ASP.NET MVC
• JavaScript and Ajax
o
• Model Validation Improvements
o
• Dependency Injection Improvements
o
• Other New Features
o
o http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx
Some new Razor features include the following:
• @model syntax for specifying the type being passed to the view.
• @* *@ comment syntax.
• The ability to specify defaults (such as layoutpage) once for an entire site.
• The Html.Raw method for displaying text without HTML-encoding it.
• Support for sharing code among multiple views (_viewstart.cshtml or _viewstart.vbhtml files).
Razor also includes new HTML helpers, such as the following:
• Chart. Renders a chart, offering the same features as the chart control in ASP.NET 4.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=597&AspxAutoDetectCookieSupport=1
• WebGrid. Renders a data grid, complete with paging and sorting functionality.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=615
• Crypto. Uses hashing algorithms to create properly salted and hashed passwords.
http://dotnetslackers.com/articles/aspnet/Experience-ASP-NET-MVC-3-Beta-New-View-Helpers-Part2.aspx#s10-the-crypto-helper
http://www.jasypt.org/howtoencryptuserpasswords.html
• WebImage. Renders an image.
http://dotnetslackers.com/articles/aspnet/Experience-ASP-NET-MVC-3-Beta-New-View-Helpers-Part2.aspx#s10-the-crypto-helper
• WebMail. Sends an email message
http://dotnetslackers.com/articles/aspnet/Experience-ASP-NET-MVC-3-Beta-New-View-Helpers-Part2.aspx#s10-the-crypto-helper
• Support for Multiple View Engines
o The Add View dialog box in ASP.NET MVC 3 lets you choose the view engine you want to work with, and the New Project dialog box lets you specify the default view engine for a project. You can choose the Web Forms view engine (ASPX), Razor, or an open-source view engine such as Spark, NHaml, or NDjango.
• Controller Improvements
Global Action Filters
Sometimes you want to perform logic either before an action method runs or after an action method runs. To support this, ASP.NET MVC 2 provided action filters. Action filters are custom attributes that provide a declarative means to add pre-action and post-action behavior to specific controller action methods. However, in some cases you might want to specify pre-action or post-action behavior that applies to all action methods. MVC 3 lets you specify global filters by adding them to the GlobalFilters collection. For more information about global action filters, see the following resources:
• Scott Guthrie's blog on the MVC 3 Preview
• Filtering in ASP.NET MVC
• JavaScript and Ajax
o
• Model Validation Improvements
o
• Dependency Injection Improvements
o
• Other New Features
o
Comments