ASP.NET Web Forms:
Asp.net uses various models for development of web pages, Asp.net web form is one of them. Here are some of the pros and cons of Asp.net web forms:
- Rich Server Controls:
- A huge toolbox basically with every control one need to develop a web application.
- We can simply drag and drop the controls in web forms; server controls will detect the browser and generate corresponding HTML code.
- There are controls like grid view which provide binding capabilities also.
- View State:
- As we all known “HTTP is a stateless protocol” controls lost their values in post back, but in Asp.net state is preserved automatically with the help of VIEW STATE. Last known values are stored on client page itself in a hidden control which is known as view state control.
- Event Driven Programming:
- Microsoft introduced event driven programming with web forms,
- Code Behind
- Self post back
- View state
- Are the main features of event driven programming.
- Developers will no more rely on POST/ GET methods for handling user interactions with server. They can simply drag the control double click it, write down the logic, that’s it. Users need not to be worried about the inner implementation.
- Rapid Application Development is achieved by Microsoft with the use of rich server controls, view state, event driven programming.
- It’s been around since 2002, there’s an abundance of information with regard to questions, answers etc.
- No Fixed Architecture:
- In web forms project architecture is not fixed.
- Developers can use three level architecture in which code is divided into UI, Business Logic and Data Access Layer or one can only choose code behind which is not considered to be a good practice.
- Unit Testing:
- In code behind sometimes we end up with lots of event handles, which makes automatic unit testing almost impossible.
- Although view state helps in preserving state of controls while post back, but view state is stored on page itself which increases page size, so reduced performance.
- Less Control Over HTML:
- Many times in web forms we are not sure what HTML we will get at the end, so making integration with java script’s framework like jquery difficult.
- Less Parallel Development:
- As aspx pages are tightly coupled with code behind so it becomes difficult to work on one section at the same time.
MVC stands for Model, View and Controller. MVC is another mechanism provided by the asp.ner to develop web applications. Here are some of the pros and cons of MVC:
- Separation of concerns:
- Asp.net MVC enforces separation of concerns, so there are less chances of getting things more complex.
- Test Driven Development:
- Controller is a separate class in MVC, so automatic testing is possible featuring test driven development.
- Controllers are not bound on specific view so they can be reused on multiple views.
- MVC doesn’t use view state to store the state of controls, reducing page size so increasing performance.
- Full control over HTML:
- Server controls are also no used in MVC, only option available is through html input controls, so we will be sure of the HTML at the time of rendering.
- Parallel Development:
- Layers in MVC are loosely coupled so we can work on each layer separately.
- Asp.net MVC supports multiple view engine’s like aspx, razor and if required we can create our own.
- More Learning Efforts:
- Absence of event driven programming model and view state makes it very difficult for beginners to understand MVC. So more learning efforts are required.
- Difficult to convert an existing site:
- It is possible to convert some pages if required but at high cost.
- Challenge if you are not running IIS7:
- .NET needs to handle all page requests to ensure that MVC pages will process, if we do not use IIS7.