BT

ASP.NET Reaches a New Milestone: ASP.NET MVC 3 Preview 1

by Abel Avram on Jul 27, 2010 |

Although ASP.NET MVC 3 Preview 1 has not been announced yet, the framework can be downloaded from Microsoft downloads. The list of new features include: Dependency Injection, Razor View Engine, Dynamic View and ViewModel properties, and Global Filters.

ASP.NET MVC 3 Preview 1 comes with new features, the most important being:

  • Razor View Engine – this view engine has been covered by InfoQ in a previous post. ASP.NET MVC 3 currently supports only C# (.cshtml files), VB.NET support being planned to be added later.
  • Dynamic View and ViewModel Properties – Views have a new dynamic View property offering simple access to the ViewData object. An example would look like this:
public ActionResult Index() {

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

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

}

<h2>View.Title</h2>

<p>View.Message</p>

Also, the Controller class has a dynamic property ViewModel offering better access to the ViewData dictionary like in this example based on the previous one:

public ActionResult Index() {

ViewModel.Title = "The Title";

ViewModel.Message = "Hello World!";

}

  • “Add View”  Dialog Supports Multiple View Engines -  The Add View dialog in Visual Studio now support the option to select from multiple view engines.
  • Dependency Injection – ASP.NET MVC now supports IoC containers to discover the following services and dependencies: controller factories, dependencies on view pages for types derived from ViewPage, ViewUserControl, ViewMasterPage, WebViewPage, for both Web Form and Razor view engines, and dependencies on action filters.
  • Global Filters – ASP.NET MVC now supports adding filters to all action methods of a controller.
  • JsonValueProviderFactory Class – This class can be used to connect client templates to action methods that receive/send JSON data.
  • Support for .NET Framework 4 Metadata Attributes

ASP.NET MVC 3 runs side by side with ASP.NET MVC 2, allowing the developer to choose which one to use. It is also possible to upgrade older projects to make use of the new framework, but the upgrade is not fully automatic. The release notes suggest to:

… create a new ASP.NET MVC 3 project and copy all the views, controllers, code, and content files from the existing MVC 2 project to the new project and then to update the assembly references in the new project to match the old project. If you have made changes to the Web.config file in the MVC 2 project, you must also merge those changes with the Web.config file in the MVC 3 project.

ASP.NET MVC 3 needs .NET 4.0 and Visual Studio 2010 or Visual Web Developer Express 2010.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT