Difference between asp.net web forms and asp.net mvc

3
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. 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.

description

Difference between ASP.NET WebForms and ASP.NET MVC

Transcript of Difference between asp.net web forms and asp.net mvc

Page 1: Difference between asp.net web forms 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 andfacilitates 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 WebFomsw.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.

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.

Page 2: Difference between asp.net web forms and asp.net mvc

The ViewState also increases the page size.

5 Learning Curve ?Relatively simple to learn and pickup. Works very well for developers who initiallyhave 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.NETMVC?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_PreInitii.Page_Initiii.Page_InitCompleteiv.Page_PreLoadv.Page_Loadvi.Page_Controlvii.Page_LoadCompleteviii.Page_PreRenderix.Page_SaveStateCompletex.Page_Render

Page Life Cycle (Process-based):i. App Initializationii. Routingiii. Instantiate and execute controlleriv. Locate and invoke controller actionv. instantiate and render view

Page 3: Difference between asp.net web forms and asp.net mvc

xi.Page_Unload

Reference:

http://onlydifferencefaqs.blogspot.in/2014/02/difference-between-aspnet-webforms-and.html