2.26.2014

Difference between ASP.NET WebForms and ASP.NET MVC


S.No
ASP.NET WebForms
ASP.NET MVC
1
What approach or pattern it uses ?
‘Page Controller’ pattern.

What does it mean?
Each page has a code-behind class that acts as a controller and is responsible for rendering the layout.
What approach or pattern it uses ?
‘Front Controller’ pattern.

What does it mean?
There is a single central controller for all pages to process web application requests and facilitates a rich routing architecture
2
Is it loosely or tightly coupled ?
Tighltly coupled.

How do you say it is tightly coupled ?
Uses an architecture that combines the Controller (code behind) and the View (.aspx). Thus the Controller has a dependency on the View.

What is the disadvantage of tightly-coupled behaviour of ASP.NET WebFoms w.r.t Test-Driven Development(TDD)?
Because of this tightly-coupled behavior, automated testing is really difficult.
Is it loosely or tightly coupled ?
Loosely coupled.

How do you say it is loosely coupled ?
The Model does not know anything about the View. The View does not know there’s a Controller.

What is the advantage of loosely-coupled behaviour of ASP.NET MVC w.r.t Test-Driven Development(TDD)?
Test driven development becomes easy because of loosely-coupled behaviour of ASP.NET MVC.
i.e., We ‘can’ test our Controller without instantiating a View and carry out unit-tests without having to run the controllers in an ASP.NET process.
3
How we can do State Management in ASP.NET WebForms?
ASP.NET WebForms manage state by using view state and server-based controls.
How we can do State Management in ASP.NET MVC?
ASP.NET MVC does not maintain state information by using view state.But, it uses light-weight state management mechanism such as: ViewBag, ViewData and TempData besides existing QueryString, HiddenFields and Session states.
4
Whether we can have full control over ASP.NET WebFoms?
No

Why we cannot have full control over ASP.NET WebForms?
WebForms supports 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.

The HTML output is not clean making it difficult to manage later.
The ViewState also increases the page size.
Whether we can have full control over ASP.NET MVC?
Yes

How do you say in ASP.NET MVC, we can have full control ?
As controller and view are not dependent and also no viewstate concept in ASP.NET MVC, so output is very clean.

No event-driven Page Life cycle like WebForms. Request cycle is simple in ASP.NET MVC model.

Full control over HTML, JavaScript and CSS.
5
Learning Curve ?
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.
Learning Curve ?
There is a learning curve to understand the why, when and how of ASP.NET MVC.
6
Amount of programming code required ?
Lesser amount of code is required to build webapps since a lot of components are integrated and provided out of the box. We can also use a lot of data controls provided out of the box that rely on ViewState.
Amount of programming code required ?
Since the application tasks are separated into different components, amount of code required is more. Since ASP.NET MVC does not use ViewState, we cannot use Data controls like GridView, Repeater.
7
Where to use ?
Works very well for small teams where focus is on rapid application development
Where to use ?
Works well for large projects where focus in on testability and maintainability
8
What syntax it uses ?
ASP.NETWebForms follow Web Forms Syntax
What syntax it uses ?
ASP.NET MVC follows customizable syntax (Razor as default)
9
What controls are used in coding ASP.NET WebForms?
Server controls.
What controls are used in coding ASP.NET MVC?
Html helpers.
10
What URL Mapping technique is used in ASP.NET WebForms ?
URL Rewriting

i,e., ASP.NET WebForms has file-based URLs means file name exist in the URLs must have its physically existence.
What URL Mapping technique is used in ASP.NET MVC ?
ASP.NET Routing

i.e., ASP.NET MVC has route-based URLs means URLs are divided into controllers and actions and moreover it is based on controller not on physical file.
11
What is used to maintain look and feel in ASP.NET WebFoms?
Master Pages
What is used to maintain look and feel in ASP.NET MVC?
Layouts
12
What is used for code reusability?
User Controls
What is used for code reusability?
Partial Views
13
Whether it is Open Source or Licensed ?
ASP.NET WebForms is not an Open Source.
Whether it is Open Source or Licensed ?
ASP.NET MVC is an Open Source.
14
Page Life Cycle (Event-based):
i.Page_PreInit
ii.Page_Init
iii.Page_InitComplete
iv.Page_PreLoad
v.Page_Load
vi.Page_Control
vii.Page_LoadComplete
viii.Page_PreRender
ix.Page_SaveStateComplete
x.Page_Render
xi.Page_Unload

Page Life Cycle (Process-based):
i. App Initialization
ii. Routing
iii. Instantiate and execute controller
iv. Locate and invoke controller action
v. instantiate and render view

No comments:

Post a Comment