Less learning effort. - Using strong server controls and ViewState developer can develop real world applications with minimal HTML and JavaScript skills.
Disadvantages:
Project Architecture
There is no fixed predefined Project Architecture for creating web applications when it comes to Web Forms. Developers have full flexibility for choosing their own architecture.
One may use basic three layered architecture dividing the system into UI, Business layer and Data access layer or a more advanced one like Model-View-Presenter. Even one may choose only code behind and write everything there which is not at all considered as good practice. Code behind is tightly connected to UI, ending up with some presentation logic.
Unit Testing
In Web Forms code behind ends up with lots of event handlers, making automatic unit testing an impossible task.
Note: as per my knowledge even with the help of mock testing (using MOQ or rhinomoq) we can’t mock ‘sender’ and ‘eventargs’ in event handlers.
And when we talk about employing TDD, unit testing code behind (presentation logic) becomes very important.
Performance
ViewState becomes solution for some problems with classic ASP but it also becomes an issue. ViewState is stored in the page itself resulting increased page size so reduced performance.
Reusability
Let’s talk about another example where we are supposed to build 2 UI
Taxable Employee screen
Nontaxable employee screen
Now most of the code behind logic is going to be same for both screens.
One solution will be, add some if conditions in code behind and create a single UI.
This will violate Single Responsibility principle which says there should be only one reason a software entity to be changed, because in this case employee form will be changed whenever any of the taxable/nontaxable information changes.
Secondly it may possible that both UI
Less Control over HTML - In Web Forms many times we are not sure about what html we will get at the end making integration with JavaScript frameworks like jQuery a difficult task
SEO –
URL’s are pointing to fixed ASPX pages which might be decorated with some query string. They are not user friendly and affect SEO.
Less support for parallel development - ASPX page are tightly coupled with code behind files. So it’s not possible that 2 different developers are working on one section (one on aspx and one on code behind) at same time.
ASP.NET 4.0
ASP.NET 4.0 has come up with some good features to overcome some of the above problems
ViewState: Provide the way to disable or control the size of the ViewState. (But there is no compulsion or fixed rule that will say to do so.)
URL routing: Using URL routing we can provide our own URL in lieu of the physical path of the page.
ID: In ASP.NET 4.0 we have better control over Id of elements and thus integration with JavaScript framework become easier. (We still don’t have complete control over HTML being generated.)
WebForms vs. MVC
Start from the beginning
