Thursday, November 15, 2018

ASP.NET Web Forms Vs ASP.NET MVC

ASP.NET Web Forms Vs ASP.NET MVC

Asp.Net Vs Asp.Net MVC
Today, ASP.NET developers have two options when building new Web projects: the old faithful ASP.NET Web Forms, or the young gun, ASP.NET MVC framework.
The difference is chalked down below:

ASP.NET Web FormsASP.NET MVC
ModelASP.NET Web Form uses traditional event driven – Page Life cycle modelASP.NET MVC application uses Pattern based model. No Page Life cycle like WebForms. Request cycle is simple in ASP.NET MVC model.
State ManagementASP.NET Web Form has some state management techniques such as session state,view state,cookies etc.ASP.NET MVC has no such state management techniques, but Model State is persisted by MVC during post backs.   Also, we can use ViewBag, View Data, Temp data for state management.
Seperation ControlsNo separation of concerns. As we discussed that every page (.aspx) has its own controller (code behind i.e. aspx.cs/.vb file), so both are tightly coupled.Very clean separation of concerns. View and Controller are neatly separate.
TestingBecause of this coupled behavior, automated testing is really difficult.Testability is a key feature in ASP.NET MVC. Test driven development is quite simple using this approach.Easier to Unit Test
StatefulnessStatefulness has a lots of problem for web environment in case of excessively large viewstate. Large viewstate means increase in page size.In order to achieve stateful behavior, viewstate is used. Purpose was to give developers the same experience of a typical WinForms application.ASP.NET MVC approach is stateless as that of the web. So there is no concept of viewstate. As controller and view are not dependent and also no viewstate concept in ASP.NET MVC, so output is very clean.
ScriptingAlong with statefulness, Microsoft tries to introduce server-side controls as in Windows applications. Purpose was to provide somehow an abstraction to the details of HTML. In ASP.NET Web Forms, minimal knowledge of HTML, JavaScript and CSS is required.In MVC, detailed knowledge of HTML, JavaScript and CSS is required.
Support over HTML,CSS ,JAVA SCRIPTSThe above abstraction was good but provides limited control over HTML, JavaScript and CSS which is necessary in many cases.Full control over HTML, JavaScript and CSS.Provides fine control over rendered HTML,Superior seperation between UI and code
LibrariesWith a lots of control libraries availability and limited knowledge of other related technologies, ASP.NET WebForms is RAD(Rapid Application Development) approach.It’s a step back. For developers decrease in productivity.
Team SizeASP.NET Web Form is good for small level applications but little bad for large applications.It needs limited team size. ASP.NET MVC is good for large Enterprise level applications. It needs large team size where different teams are working together.Bigger ramp-up and training required for developers with little or no experience in Web application development
SyntaxASP.NET Web Form uses web forms syntax .ASP.NET MVC uses some default customize syntax such as ASPX engine for  MVC1   and  MVC2 templates, and Razor engine for MVC3 , MVC4 and MVC5 templates.
ControlASP.NET Web Forms use 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. HTML Helpers are used.
Master Page & LayoutsASP.NET Web Form uses Master pages for look and feel of the web page.ASP.NET MVC uses Layouts for look and feel of the web page.
Routing: URLs ExistenceASP.NET Web Form is a file based URLs. Means file names exist in URLs must have a physical existence in the application.ASP.NET MVC application uses URLs Routing concepts. Means URLs are separated in Controllers , actions and others. It is based on Controller, not on Physical file.
Open SourceASP.NET Web Form does not follow open source concepts.While ASP.NET MVC application follow open source concepts.
Design and logic codesASP.NET Web Form are tightly coupled models. Means Design and Logic’s codes are present in one file( ASPX.CS ).While ASP.NET MVC are loosely coupled models. Means views and logic are loosely coupled because views and logic’s are kept in separate file.
Interactive ApplicationASP.NET Web form is strong data access model.Heavy page size due to view state management; so it is not helpful to develop an interactive application.ASP.NET MVC is a light weight application .Typical size of page is small.This is best to develop an interactive application.
 View EnginesProvides very good RAD Development capabiltiesCan support multiple view engines
 Design SupportGreat designer support in Visual StudioBy default uses RESTful interfaces for URL’s so better SEO
IntegrationEasy for development for heavy Database LOB applicationsEasy Integration with Frameworks like JQuery
Control librariesVery rich control libraries and third party binder supportNot event driven, so may be difficult for people who know only ASP.net webforms to wrap their minds around it.
 UI SupportHarder to adopt to various UI views desipte the various frameworks available ( master pages, themes etc )Third party library support is not that strong
UI logic coupies with the code and thus hard to spepeateAllows for reuse of the same models to present different UIs and interfaces.
Great to creating quick prototypes for business applications. This comes in very handy when trying to show quick Proof of Concept to cleints

http://www.anarsolutions.com/asp-net-web-forms-vs-asp-net-mvc/utm-source=Blogger.com

No comments:

Post a Comment