-->

27/08/2011

Features of MVC 3.0

# Extensible Scaffolding with MvcScaffold integration
     The new Scaffolding system makes it easier to pick up and start using productively if you’re entirely new to the framework, and to automate common development tasks if you’re experienced and already know what you’re doing.
     This gave a provision of using and even modifying the scaffold template as per your requirements. This topic is being discussed in detail in my other posts.

# HTML 5 Project Templates
     The new project template supports HTML5 template, which have far better performance and compatibility advantages compared with earlier versions of rendering formats. The advantages of HTML5 were discussed separately in my next post.


# The Razor View Engine
     ASP.NET MVC 3 comes with a new view engine named Razor that offers the following benefits:
             1. Clean & Concise Code
             2. Intellisense support for Razor in VS 2010
             3. @Inherits System.Web.Mvc.WebViewPage<TModel> replaced by @model TModel
             4. MaterPages in MVC 2.0 replaced by Layouts in MVC3.0 , providing greater flexibility and ease of implementation.
             5. Introduction of HTML.Raw() methods for better control of encoding and decoding.
             6. _Viewstart.cshtml file in Shared folder used to share the common functionality between all the views.
             7. A whole new bunch of html helper class supporting different functionality like Rendering charts, Images, Password algorithms, web emails.

# Support for Multiple View Engines
     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.

#Global Filters or Action Methods()
     MVC 3.0 supports Filter methods, which can be assigned to any property in a Model decaraltively. Example : See "Remote Validation in MVC" post, where i shown how to use and implement Filter Action methods ().

# New "ViewBag" Property
     Earlier in MVC 2.0, we use ViewData property, which is very hard to use. 
Syntax in 2.0 : ViewData["Message"]="Message Text";
Now, we have ViewBag where you can get or set the values dynamically.
Internally, ViewBag properties are stored as name/value pairs in the ViewData dictionary.   
Syntax in 3.0 : ViewBag.Message="Message Text" ;


# JavaScript and Ajax Improvements

     Ajax callback methods and client side validation helpers in MVC 3 use an unobtrusive JavaScript approach. Unobtrusive JavaScript avoids injecting inline JavaScript into HTML. This makes your HTML smaller and less cluttered, and makes it easier to swap out or customize JavaScript libraries.
      Client side validations are also can be controlled at different levels from web.config files.
 <appSettings>
  <add key="ClientValidationEnabled" value="true"/> 
  <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
 </appSettings> 
    You have to include the following in-built script for using unObtrusive Javascript.
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" 
 type="text/javascript"></script> 

#
JSON Binding Support
ASP.NET MVC 3 includes built-in JSON binding support that enables action
methods to receive JSON-encoded data and model-bind it to action-method
parameters. This capability is useful in scenarios involving client templates
and data binding. MVC 3 enables you to easily connect client templates with
action methods on the server that send and receive JSON data.  

# Validation Improvements in Model
     The IValidatableObject interface enables you to perform model-level validation, and it enables you to provide validation error messages that are specific to the state of the overall model, or between two properties within the model. MVC 3 now retrieves errors from the IValidatableObject interface when model binding, and automatically flags or highlights affected fields within a view using the built-in HTML form helpers.     The IClientValidatable interface enables ASP.NET MVC to discover at run time whether a validator has support for client validation. This interface has been designed so that it can be integrated with a variety of validation frameworks.
# Dependency Injection Improvements
This provides better support for applying Dependency Injection (DI) and
for integrating with Dependency Injection or Inversion of Control (IOC)
containers. Support for DI has been added in the following areas:

  • Controllers (registering and injecting controller factories, injecting controllers).
  • Views (registering and injecting view engines, injecting dependencies into view pages).
  • Action filters (locating and injecting filters).
  • Model binders (registering and injecting).
  • Model validation providers (registering and injecting).
  • Model metadata providers (registering and injecting).
  • Value providers (registering and injecting).
     The Dependency Injection improvements will be discussed in a separate post in detail with demo applications.

Is it helpful for you? Kindly let me know your comments / Questions.

1 comment:

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.
    html5 audio player

    ReplyDelete