Saturday, May 18, 2013

Top 10 New Features in ASP.net MVC 4

What is New in ASP.net MVC 4 ?

Feature 1 : ASP.net Web API

      What is ASP.net Web API ?

  • A New framework for creating HTTP services
  • That can reach a broad range of clients including browsers and mobile devices
  • Web API is also an ideal platform for building RESTful services

Feature 2 : Enhancements to Default Project Templates

  • The Template that is used to create new ASP.net MVC 4 projects has been updated to create a more modern-looking websites

Enhancements to Default Project Templates

  • In addition to cosmetic improvements, there’s improved functionality in the new template
  • The Template employs a technique called Responsive Design to look good in both desktop browsers and mobile browsers without any customization

mobile browsers without any customization


How to See Responsive Design in Action ?
  • You can use a mobile emulator or just try re-sizing the desktop browser window to be smaller
  • When the browser window gets small enough, the layout of the page will change

What is Responsive Web Design (RWD) ?
  • Is a web design approach aimed at crafting sites to provide an optimal viewing experience
  • Easy reading and navigation with a minimum of re-sizing  panning, and scrolling across a wide range of devices (from desktop computer monitors to mobile phones)

Feature 3 : Mobile Project Template

  • If you’re starting a new project and want to create a site specifically for mobile and tablet browsers
  • Then you can use the new Mobile Application project Template
  • This is based on jQuery Mobile, an open-source library for building touch-optimized UI
  • This template contains the same application structure as the Internet Application template and the controller code is virtually identical
  • But it's styled using jQuery Mobile

Mobile Project Template


styled using jQuery Mobile



Feature 4 : Display Modes

  • Lets an application select views depending on the browser that's making the request

For example :
  • If a desktop browser requests the Home page, the application might use the Views\Home\Index.cshtml template
  • If a mobile browser requests the Home page, the application might return the Views\Home\Index.mobile.cshtml template
  • Layouts and Partials can also be overridden for particular browser types

That is :

Layouts :
  • If your Views\Shared folder contains both the _Layout.cshtml and _Layout.mobile.cshtml templates,
  • Then by default the application will use _Layout.mobile.cshtml during requests from mobile browsers and _Layout.cshtml during other requests

Partials :
  • If a folder contains both _MyPartial.cshtml and _MyPartial.mobile.cshtml,
  • The instruction @Html.Partial("_MyPartial") will render _MyPartial.mobile.cshtml during requests from mobile browsers, and _MyPartial.cshtml during other requests

Feature 5 : jQuery Mobile and Mobile Features


  • The jQuery Mobile library provides a user interface framework that works on all the major mobile browsers
  • jQuery Mobile applies progressive enhancement to mobile browsers that support CSS and JavaScript
  • Progressive enhancement allows all browsers to display the basic content of a web page, while allowing more powerful browsers and devices to have a richer display
  • The JavaScript and CSS files that are included with jQuery Mobile style many elements to fit mobile browsers without making any markup changes
  • You can install the jQuery.Mobile.MVC NuGet package, which installs jQuery Mobile and a view-switcher widget


Feature 6 : Task Support for Asynchronous Controllers

  • You can now write asynchronous action methods as single methods that return an object of type Task or Task<ActionResult>

Feature 7 : Azure SDK

  • ASP.net MVC 4 supports the Newer release of the Windows Azure SDK 2.0

Feature 8 : Database Migrations

  • ASP.net MVC 4 projects now include Entity Framework 5
  • One of the great features in Entity Framework 5 is support for database migrations
  • This feature enables you to easily evolve your database schema using a code-focused migration while preserving the data in the database

Feature 9 : Bundling and Minification

  • The bundling and minification framework enables you to reduce the number of HTTP requests
  • That a Web page needs to make by combining individual files into a single,
  • Bundled file for scripts and CSS
  • It can then reduce the overall size of those requests by minifying the contents of the bundle

What is Minifying ?
  • Minifying can include activities like eliminating white space to shortening variable names to even collapsing CSS selectors based on their semantics

How to Handle Bundles ?
  • Bundles are declared and configured in code and are easily referenced in views via helper methods
  • Which can generate either a single link to the bundle or,
  • When debugging, multiple links to the individual contents of the bundle

Feature 10 : Enabling Logins from Facebook and Other Sites Using OAuth
                            and OpenID

  • The default templates in ASP.net MVC 4 Internet Project template now includes support for OAuth and OpenID login using the DotNetOpenAuth library
  • It's on App_Start ==> AuthConfig.cs File


Do You Have Any Problem or Things to Share about ASP.net MVC 4 ?

MVC 4 on Linkedin



Conclusion
  • You can see that lots of new and awesome features have been added to the ASP.net MVC4
  • So, use them and enjoy it

I hope this helps to You.Comments and feedback greatly appreciated.

If you feel it was a good article,Give me a +1.Thank You.




Happy Coding.

17 comments:

  1. Replies
    1. Hi Mukesh,

      Thanks for your feedback.
      Keep in Touch.

      Delete
  2. Good work sampath! Probably you should nominate your self for Microsoft MVP

    ReplyDelete
    Replies
    1. Hi RAZIN,

      Thanks for your suggestion and motivation.
      Keep in Touch.

      Delete
  3. Hey nice one ... Great stuff .. ;)

    ReplyDelete
  4. Thanks Sampath, got to know about couple of new intresting features. I was wondering, if we dont have Layout.mobile.cstml but have implemented JQuery to handle the Responsive technique, should work right?

    ReplyDelete
    Replies
    1. Hi Priyanka,

      Yes.You need "Layout.mobile.cshtml" only when you have decided to give separate layout for the mobile devices.Otherwise Out of the box ASP.net default Template gives Responsiveness nature.So you don't need to do anything for achieve that.
      I feel I gave answer for you're query.If you have more queries Plz let me know.

      Delete
  5. Hi,
    Good work, got to know some new concepts regarding mobile developemetn.
    I think WEB API is released with MVC 4 but it is not a part of asp .net MVC, even you can check the wep api file there you can't find the Using System.Web.MVC namespace. It is a new enhancement to asp .net WCF.

    ReplyDelete
    Replies
    1. Hi Ravikumar,

      Thanks for your feedback.

      About your Concern:

      ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.So it's not a part of MVC.It is for build HTTP services with any application type.If you need you could use it with MVC also.

      Delete
  6. Replies
    1. Hi ramagopi,

      You're warmly welcome.
      Keep in Touch.

      Delete
  7. Effective explanation, good collection. thanks fro sharing

    ReplyDelete
    Replies
    1. Hi Suresh,

      Thanks, I’m glad you enjoyed it :)

      Delete
  8. Really Nice presentation Sampath. Easy and simple to understand.
    I have one query regarding Microsoft certification.Which is best certification suitable for Asp.net MVC..How to do it?

    ReplyDelete

Thanks for your Feedback.