What are the key difference between ASP.NET Webforms & ASP.NET MVC?


Here are some points that differentiate ASP.NET Web Forms from ASP.NET MVC:

  1. Webform Uses the ‘Page Controller’ pattern. Each page has a code-behind class that acts as a controller and is responsible for rendering the layout. MVC Uses the ‘Front Controller’ pattern. There is a single central controller for all pages to process web application requests and facilitates a rich routing architecture.
  2. Webform Uses an architecture that combines the Controller (code behind) and the View (.aspx). Thus the Controller has a dependency on the View. Due to this, testing and maintainability becomes an issue. MVC enforces a “separation of concerns”. The Model does not know anything about the View. The View does not know there’s a Controller. This makes MVC applications easier to test and maintain.
  3. In Webform the view is called before the controller, while in MVC Controller renders View based on actions as a result of the User Interactions on the UI.
  4. At Webforms core, you ‘cannot’ test your controller without instantiating a View. There are ways to get around it using tools. While ASP.NET MVC was designed to make test-driven development easier. You ‘can’ test your Controller without instantiating a View and carry out unit-tests without having to run the controllers in an ASP.NET process.
  5. WebForms manage state by using Viewstate and server-based controls. While MVC does not maintain state information by using Viewstate.
  6. WebForms support an event-driven programming style that is like Windows applications and is abstracted from the user. The State management is made transparent by using sessions, Viewstate etc… In the process, the HTML output is not clean making it difficult to manage later. The ViewState also increases your page size. In ASP.NET MVC, the output is clean and you have full control over the rendered HTML. The orientation is towards building standard compliant pages and provides full control over the behavior of an application.
  7. Deep understanding of HTML, CSS and JavaScript is not required to a large extent since the WebForm model abstracts a lot of these details and provides automatic plumbing. While abstracting details to provide ease of use, sometimes a solution is overcomplicated, than it needs to be. In MVC, A thorough understanding of how HTML, CSS and JavaScript work together is required. The advantage is you can do a lot of jQuery and AJAX stuff in an efficient and simple manner than you would do in an ASP.NET application.
  8. WebForms can drastically reduce time while building up intranet and internet applications that use a lot of controls (drag and drop model). Although this is true for development, a lot of time is spent later to code around limitations. In MVC, You lose the ‘drag and drop’ quick model of building your web applications. The focus is on control over the application behavior and test-driven development. The model is extensible and you do not have to spend time working around limitations.
  9. Relatively simple to learn and pickup. Works very well for developers who initially have trouble with the HTTP/HTML model and are coming from a similar WinForms oriented event model. In MVC, There is a learning curve to understand the why, when and how of ASP.NET MVC.
  10. Lesser amount of code is required to build Webapps since a lot of components are integrated and provided out of the box. You can also use a lot of data controls provided out of the box that rely on ViewState. In MVC, since the application tasks are separated into different components, amount of code required is more. Since ASP.NET MVC does not use ViewState, you cannot use Data controls like GridView, Repeater.
  11. Webforms works very well for small teams where focus is on rapid application development. MVC works well for large projects where focus in on testability and maintainability.

Reference : here

Advertisements

2 thoughts on “What are the key difference between ASP.NET Webforms & ASP.NET MVC?

  1. I do enjoy the manner in which you have presented this
    concern and it does supply me a lot of fodder for thought.
    However, through just what I have witnessed, I basically
    trust when other comments pile on that men and women continue to be on issue and don’t get started upon a tirade of the news du jour. Still, thank you for this exceptional point and although I do not really agree with this in totality, I value your standpoint.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s