ASP.NET MVC Vs ASP.NET Web Form

Lately I have come across 2 frameworks that are quite similar, as it is out from ASP.NET, it is quite a hard choice to choose which framework is suitable to develop the system. What is the constraints and requirements need to be consider? Well I have done some reading in it and I will post it below:

so what is the difference between them?

ASP.NET MVC Vs ASP.NET Web Form

ASP.NET MVC ASP.NET Web Form
1 Unit testing (TDD) Able It is impossible to be perform because the page life cycle of the Web Form is too complex and has the tightly coupling between all things in the ASP.net framework and a single class is used both to display output and handles user input.
2 Viewstate, Postback, server control,server based form to enable full

control over the application and

html

No, able to follow agile methodologies and practices since web is a stateless things Yes, sometimes even small size of web page may affect the performance of the application
3 Make search engine optimization(SEO) URLs publish by application Able, Use Representational state transfer (REST) based URL Not able, Use file-name extension
4 .Net Framework supported .Net Framework 3.5 .Net Framework 2.0
5 Allow to build highly testable, maintainable loosely coupled applicationsĀ  (test driven development) RAD development
6 Integrate with JavaScriptFrameworks Yes Not able to integrate with JavaScript Frameworks due to the naming conventions of rendered HTML
7 Good for public face application Good choice for small projects, build quick application with less than 1000 users
8 Powerful to add admin stuff and things that render to thousands of users

1. Do you need test driven development?

-web form use single file for all 3 roles which makes testing complicated

-MVC, we can test controller or model separately using other testing framework

2. Is it important to have URL mapping?

-MVC, not associated with some page, physically stored on server, this makes URL mapping easier which is good for search engine optimization (SEO).

-web form, does support MVC features, every user request is associated with some .aspx page.

3. Support multiple views?

-MVC, multiple views can work with single model or controller. Then for different clients you can use different views. Different browser or older version of browser may need different view, this make application not that complex, and easy to maintain.

4. Is the need of separation a concern?

-web form, all code is in single file, making it so complex

-MVC, data access code is in model, output in view, code for user interaction in controller make application less complex and easy for testing

5. Do you need complete control over generated HTML output?

-The main difference between Views and Web Forms is that View haven’t <form > tag with runat=”server” attribute. In code behind there is no page Init or Load methods, no event handlers. There is only class declaration inherited from ViewPage class (unlike Web Forms that inherit Page class). There are no form’s controls with client IDs and no ViewState object. MVC HTML output contains only what you put in it with no surprise in form of large hidden field or JavaScript. Because of this, MVC pages are usually smaller than Web Forms, load faster and spend less bandwidth.

And here is the swot analysis:

So here are some information that able to help you to make the decision. But you do not need to be a technical-framework-nazi, sticking to one of them. It is ok for both, depends on the requirements and the methodology you are using for developing the application.

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