Friday, January 12, 2018

Why MVC is fast

ASP.NET Web Form Problems:

Complexity : HTML and ASP.NET mark up code are used in a Single Page that's why code become very complex.

Tightly Coupled-Aspx page and cs page(code behind file) are tightly that we can not work separately.

Unwanted Html and Java Script : When we drag and drop the controls then unwanted html and java script is automatically inserted in our code that's why page become heavier and it takes time to load on browser.

View state-One of the main problems with ASP.NET web forms is the viewstate mechanism, which takes a lot of bandwidth because it serializes all the form inputs and sends it on post commands.

Response Time -for any single events it follows the complete Page Life cycle Events life cycle that's why response time of any ASP.NET application is become more than the MVC application.

Benefits of MVC

Separation of Concerns -In MVC  every part is spearated UI, Business Logic , Model. Clean separation of UI.

More Control-The ASP.NET MVC framework provides more control over the HTML , JavaScript and CSS than the traditional Web Forms.

Testability- Is it testabel using unit test cases, wile ASP .Net was not.

Lightweight-ASP.NET MVC framework doesn’t use View State and thus reduces the bandwidth of the requests to an extent.

Full features of ASP.NET-One of the key advantages of using ASP.NET MVC is that it is built on top of ASP.NET framework and hence most of the features of the ASP.NET like membership providers , roles etc can still be used.

.  SEO friendly URL by design (though now this is possible in ASP.NET 4 as well)

-  Session, JS, Ajax works.  Validation is even more powerful with DataAnnotations and jquery.
-Business logic is stored in a single state called model where in traditional platform, each page has its own business logic making it complex.

--View based solution for Action based requirement
--HTML is not the only response type

Because of the tight coupling between view and code behind even the response type is fixed in webform , its by default HTML. If you wish to change it you need to play around with Content-type and “Response.End” methods etc which is quiet tedious.

If we create “Action” first structure then the action has all the luxury in the world to decide what kind of response type should go out. This makes our system more flexible in terms of same action with different outputs.

 FlexibleCombination of view and data

Making behind code a normal class for unit testing

No comments: