UPDATE: This ASP.NET MVC tutorial initially targetting MVC3, MVC4 and MVC5 version. Now I have listed down features from next version of ASP.NET MVC6 (code name as ASP.NET vNext).
Microsoft has added exciting features in every new version of ASP.NET MVC that make developers more comfortable building scalable web applications easily. In this ASP.NET MVC tutorial, we will have a quick look into new and important features introduced in major versions of Microsoft ASP.NET MVC starting fromMVC3 to MVC5 (the latest one so far).
MVC3 Vs MVC4 Vs MVC5 Vs MVC6
Note: If you wanted to get a practical example for building your first ASP.NET MVC 5 Application using Entity Framework, please follow here.
ASP.NET MVC3
- New Project Templates having support for HTML 5 andCSS 3.
- Improved Model validation.
- Razor View Engine introduced with a bundle of new features.
- Having support for Multiple View Engines i.e. Web Forms view engine, Razor or open source. You can follow here for a detailed comparison on difference betweenWebForm View Engine and Razor View Engine.
- Controller improvements like ViewBag dynamic property and ActionResults Types etc. Dynamic property is a new feature introduced in C# 4.0. ViewBag being a dynamic property has an advantage over ViewData that it doesn’t require checking NULL values. For detailed difference between ViewBag and ViewData can be foundhere.
Related Articles
- Unobtrusive JavaScript approach that actually separates the functionality from presentation layer on a web page.
- Improved Dependency Injection with new IDependencyResolver.
- Partial page output caching.
ASP.NET MVC 4
- ASP.NET Web API, a framework that simplifies the creation of HTTP services and serving a wide range of clients. Follow to create your first ASP.NET Web API service.
- Adaptive rendering and other look-n-feel improvements to Default Project Templates.
- A truly Empty Project Template.
- Based on jQuery Mobile, new Mobile Project Template introduced.
- Support for adding controller to other project folders also.
- Task Support for Asynchronous Controllers.
- Controlling Bundling and Minification through web.config.
- Support for OAuth and OpenID logins using DotNetOpenAuth library.
- Support for Windows Azure SDK 1.6 and new releases.
ASP.NET MVC5
- ASP.NET Identity for authentication and identity management. Thesedays, modern applications are developed for broader range of clients such as web, mobile in mind. Also, users are actively using their social identities from various social channels like facebook, youtube, twitter etc. ASP.NET Identity is a new Membership system to handle authentication and authorization for variety of clients as well as using user’s existing social identities.
- Authentication Filters for authenticating user by custom or third-party authentication provider.
- With the help of Filter overrides, we can now override filters on a method or controller.
- Bootstrap replaced the default MVC template.
- Attribute Routing is now integrated into MVC5. Basically, MVC Routing is an excellent way to create human friendly and Search Engine Optimized URLs. You can easily get understanding about Routing in ASP.NET MVC here. Attribute based routing enables us to define routes along with action methods as follows:
[Route(“Students/{id}”)]
public ActionResult GetStudentById(string id)
{
// code logic here.
return View();
}
public ActionResult GetStudentById(string id)
{
// code logic here.
return View();
}
ASP.NET MVC6 | ASP.NET vNext
- Single Programming Model for ASP.NET MVC and ASP.NET Web API.
- Optimized for Cloud Computing.
- Supporting side by side deployment of runtime and framework along with application.
- Out of the box support for dependency injection.
- vNext is Open Source and supports running on multiple platforms including Linux and Mac.
- New JSON-based project Extension.
- In order to dynamically compile code, Roslyn compiler is used.
Hopefully, this article will help you in comparing core features of ASP.NET MVC in different versions.
The main purpose of the MVC (Model, View and Controller) architecture is to make separation of the business layer (logic) and the application layer (data) from the presentation layer to the user.
Difference between MVC2, MVC3 and MVC4 |
View Engine :View Engine is responsible for rendering of the HTML code from your views to the browser. MVC 2 uses only Web Forms view engine (.aspx) as a default View Engine. MVC3 uses Razor View Engine (.cshtml for c# and .vbhtml for Visual Basic) and Web Forms view engine (.aspx). MVC4 also uses Razor View Engine as a default view engine with some new features like condition attribute and ‘Tilde slash’. |
Chart, WebGrid, Crypto,WebImage, WebMail Controls : All these are not available in MVC2. All these are available in MVC3 and in MVC4. |
Syntex : (HTML Syntax) Web Forms view engine syntax: <%=Html code %> in MVC2. (Razor Syntax) Razor View Engine syntax: @Html code in MVC3. MVC4 has the same Razor View Engine Syntax but with the addition of new features like conditional attribute and ‘Tilde Slash’ i.e. URL resolution. |
Objects available for sharing of data between View and Controller : TempData, ViewData are available in MVC2. TempData, ViewData ,ViewBag are available in MVC3. TempData, ViewData ,ViewBag are available in MVC4.> TempData is used with current and subsequent request i.e. when you know the next view to be redirected.
> In ViewData, dictionary of objects are accessible via strings as keys.
> ViewBag was added in the C# 4.0 which uses the dynamic feature that allows to add properties of an object dynamically . We can say that ViewBag = ViewData + dynamic feature around the ViewData dictionary.
|
Jquery Support : Jquery support is Good in MVC2. Jquery support is Better in MVC3. MVC4 provides better support for Jquery like Jquery Mobile. |
Dependency Injection Support : Dependency injection is Good in MVC2. It provides powerful hooks with Dependency Injection and Global Action Filters in MVC3. Better support in MVC4. |
Layout Support : Supports only Master Page in MVC2. Supports not only Master Page but also Layout Page in MVC 3 and in MVC4. |
Validation : Client-side Validation and Asynchronous controllers is there in MVC2. Unobtrusive Ajax and Client side Validation, Jquery Validation and JSON binding support is in MVC3. Client side validation, Jquery validation and enhanced support for asynchronous methods in MVC4. |
Project Templates : MVC3 supports project templates enabled by HTML 5. MVC4 supports many new features for mobile apps and also provides new mobile project template and default templates are refreshed and modernized.
MVC 2
MVC 3
MVC 4
|
No comments:
Post a Comment