ASP.NET MVC 3.0 New Features

ASP.NET MVC 3.0 is the major change of ASP.NET MVC framework. The great news is that it is compatible with the previous release, which means you can easily update your project from MVC 2 to MVC 3.0. The new features which are build on the top of core framework, it is already learned by the community of developers, so no need to worry about the learning curve.

You have to just grip on the new features which provide us an opportunity to know about some features and implement it. I take an example of the core feature like RedirectPermanent method, how important addition it is, I realize today when my team lead told me to redirect the website about page to Login page but with permanent redirect. I said him; no problem ASP.NET core feature is available now.

Now we discuss some new features recently added are as follows:

Razor View Engine

It is the result of code focused template approach. Minimize the code, compact and very easy to learn. We can say it is not a new language; we can use C#.NET or VB.NET which we have already worked on. Very quick and productive and has built in intellisense support with Visual Studio. No app domain or web server is required for unit testing. The most amazing thing is that it is pluggable.

  • We can use @model syntax for specifying the type being passed to the view
  • Master page like default for entire website such as (layoutpage)
  • If you want to display the text without HTML-encoding, use Html.Raw method
  • A new way to add comment like @* this is comment *@
  • Sharing code among multiple views is possible now using _viewstart.cshtml for C# and _viewstart.vbhtml file for VB.NET

View Property

A new dynamic View property is added, you can try the magic of this property. View property provides you a simpler syntax to access the ViewData dictionary.

public ActionResult Hello() {
       ViewData[“PageTitle”] = “My Title”;
       ViewData[“BodyMessage”] = “I am using View property”;
}

The both properties can be accessed in the Hello view using code mentioned below:

<Title>View.PageTitle</Title>
<Body>View.BodyMessage<Body>

ViewModel Property

We used ViewData property to pass data to view template using late-bound dictionary API. It is still supported but we have a new dynamic property called ViewModel property, which provides a cleaner syntax and there is no need to define any strongly typed classes to ViewModel property. You just need to get and set properties on it and it will resolve them dynamicall at runtime. It stored name/value pairs within ViewData dictionary.

New ActionResult Types

Redirect Permanent(), RedirectToRoutePermanent() and RedirectToActionPermanent() methods are introduced for permanently redirection which returns HttpRedirectResult.

HttpNotFoundResult is another addition, it returns 404 HTTP status code to the client.

We can set status code and description explicitly using HttpStatusCodeResult class.

Javascript and AJAX Improvements
ASP.NET MVC 3 has the built-in support of JSON, which permit the action methods to receive JSON-encoded data using action method parameters.

Model Validation: DataAnnotation metadata attribute like DisplayAttribute is supported now in MVC 3.

ASP.NET MVC 3 supports the new .NET 4 DataAnnotations metadata attributes such as DisplayAttribute, IValidatableObject interface and IClientValidatable interface.

The Dependency Injection support is improved and we have bettor support of  integration with Dependency Injection / IOC containers. Common Service Locator library support and Global filters are also added.

You can further investigate the newly added features using the following resources. I just tried to summarize the available changes. If find any spelling mistake or another issue in this article then please add the comments. Any comment will be heartedly  appreciated regarding this article. Thanks in advance.

http://www.asp.net/mvc/mvc3
http://weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview-1.aspx
http://weblogs.asp.net/imranbaloch/archive/2011/01/16/asp-net-mvc-3-new-features.aspx

ASP.NET MVC , , ,

5 comments


  1. Pingback: ASP.NET MVC Archived Buzz, Page 1

  2. Ira

    Greetings I stumbled on your blog by mistake when i was searching Msn for this topic, I must tell you your website is quite valuable I also love the style, its amazing!

  3. waqar

    Its indeed a very good article.you summarize quite well.I appreciate the knowledge u shared and we would be expecting that you gonna share your knowledge in future as well.

  4. Gretchen Romney

    My name is Gretchen Romney and I am an devoted reader of personal blogs. I spotted yours on Aol. You actually had me personally at ASP.NET MVC 3.0 New Features | Rais Hussain. Exactly how long have you been submitting posts? %

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>