Introduction to ASP.NET MVC 4:
Before start with ASP.NET MVC 4 application let's understand the following,
- What is ASP.NET MVC
- Advantages of MVC framework over web form approach
- When to choose MVC
- Difference between ASP.NET MVC and ASP.NET web form
What is ASP.NET MVC :
ASP.NET MVC is a new web application framework from Microsoft,is used for developing web sites with support of HTML, javascript, css and also .NET language. MVC stands for Model-View-Controller. ASP.NET MVC is an alternative and a complement to Web Forms, this is not a replacement of asp.net web-form, which means you won’t be dealing with pages and controls, post backs or view state, or complicated ASP.NET event life cycle.This is just an option of developing web site with support of MVC design pattern .
In Short :
View - Takes the responsibility of UI
Controller – Takes the responsibility of user inputs
Models- Takes the responsibility of business logic
Models- Takes the responsibility of business logic
Advantages of MVC framework over web form approach :
One question arises,what is the advantage we get when we go for asp.net mvc option.
- Separation of concerns/Loose coupling : Strict isolation between the individual parts of an application , that is we can decouple things and concentrate on our requirement in proper manner (separate business logic,user interface and data layer).
- TDD : Better Support For Test Driven Development
- Full control over application behavior :ASP.NET MVC framework doesn’t use View State or server based forms like Web Forms. This gives the application developer more control over the behaviors of the application and also reduces the bandwidth of requests to the server.
- Better For Search Engine Optimization : ASP.NET MVC framework supports a powerful URL routing mechanism that helps to build a more comprehensible and search able URLs in the application.
When to choose ASP.NET MVC :
- When we think about we want to build separate user interface, user Input and business logic.
- When we want to build reach asp.net application .
- It’s better as well as recommended approach for large-scale applications where different teams are working together.
Difference between ASP. Net MVC and ASP. Net Web form :
General differences between ASP.NET MVC and ASP.NET Web form are,
ASP.NET Web Form | ASP.NET MVC |
ASP.NET Web Forms uses Page controller pattern approach for rendering layout. In this approach, every page has its own controller, i.e, code-behind file that processes the request. | ASP.NET MVC uses Front Controller approach. That approach means a common controller for all pages processes the requests. |
It uses view state or server-based forms, which can make managing state information easier. | It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application. |
No separation of concerns. Every page (.aspx) has its own controller (code behind i.e. aspx.cs/.vb file), so both are tightly coupled. | ASP.NET MVC enforces a "separation of concerns", in which the application is divided into the model, view, and controller parts of the application. This makes MVC applications easier to test and maintain. |
ASP.NET web form model follows a Page Life cycle. | No page life cycle in ASP.NET MVC. Request cycle is simple in ASP.NET MVC model |
Asp.Net Web Form has Master Pages for consistent look and feels. | Asp.Net MVC has Layouts for consistent look and feels. |
Asp.Net Web Form has User Controls for code re-usability. | Asp.Net MVC has Partial Views for code re-usability. |
Asp.Net Web Form is not Open Source. | Asp.Net MVC is an Open Source. |
Hope this will clear the basic understanding on MVC .
See my next article on Create First ASP.NET MVC 4 Web Application
See my next article on Create First ASP.NET MVC 4 Web Application
Happy Reading :-)