Wednesday, July 20, 2011

What’s Wrong with ASP.NET Web Forms?

What a great description of all the deficiencies of ASP.NET Web Forms! The following is an excerpt from Pro ASP.NET MVC 3 Framework by Adam Freeman and Steven Sanderson (Apress).

What’s Wrong with ASP.NET Web Forms?
Traditional ASP.NET Web Forms development was a great idea, but reality proved more complicated.
Over time, the use of Web Forms in real-world projects highlighted some shortcomings:
•  View State weight: The actual mechanism for maintaining state across requests
(known as View State) results in large blocks of data being transferred between the
client and server. This data can reach hundreds of kilobytes in even modest web
applications, and it goes back and forth with every request, frustrating site visitors
with slower response times and increasing the bandwidth demands of the server.
•  Page life cycle: The mechanism for connecting client-side events with server-side
event handler code, part of the page life cycle, can be extraordinarily complicated
and delicate. Few developers have success manipulating the control hierarchy at
runtime without getting View State errors or finding that some event handlers
mysteriously fail to execute.
•  False sense of separation of concerns: ASP.NET’s code-behind model provides a
means to take application code out of its HTML markup and into a separate code-
behind class. This has been widely applauded for separating logic and
presentation, but in reality, developers are encouraged to mix presentation code
(for example, manipulating the server-side control tree) with their application
logic (for example, manipulating database data) in these same monstrous code-
behind classes. The end result can be fragile and unintelligible.
•  Limited control over HTML: Server controls render themselves as HTML, but not
necessarily the HTML you want. Prior to ASP.NET 4, the HTML output usually
failed to comply with web standards or make good use of Cascading Style Sheets
(CSS), and server controls generated unpredictable and complex ID values that are
hard to access using JavaScript. These problems are reduced in ASP.NET 4, but it
can still be tricky to get the HTML you expect.
•  Leaky abstraction: Web Forms tries to hide away HTML and HTTP wherever
possible. As you try to implement custom behaviors, you frequently fall out of the
abstraction, which forces you to reverse-engineer the postback event mechanism
or perform obtuse acts to make it generate the desired HTML. Plus, all this
abstraction can act as a frustrating barrier for competent web developers. 
•  Low testability: The designers of ASP.NET could not have anticipated that
automated testing would become an essential component of software
development. Not surprisingly, the tightly coupled architecture they designed is
unsuitable for unit testing. Integration testing can be a challenge, too.
ASP.NET has kept moving. Version 2.0 added a set of standard application components that can
reduce the amount of code you need to write yourself. The AJAX release in 2007 was Microsoft’s
response to the Web 2.0/AJAX frenzy of the day, supporting rich client-side interactivity while keeping
developers’ lives simple. The most recent release, ASP.NET 4, produces more predictable and standards-
compliant HTML markup, but many of the intrinsic limitations remain.

Comments (10)

Loading... Logging you in...
  • Logged in as
Login or signup now to comment.
thanks for sharing
Reply
Don't you think asp.net forms are a bit heavy?
Reply
I have come across a lot of Asp.Net programmer who hardly works with this kind of web forms. Thanks for the blog!
Reply
The developers of ASP.NET could not have expected that automated examining would become an extremely important part of software development. Obviously, the firmly combined structure they designed is unsuitable for device examining. Incorporation examining can be a task, too.ASP.NET has kept shifting.
Reply
What rubbish, another typical geek response to purist claptrap. Oh this doesnt operate in that parsec or that doesnt do this utilising bit 3 or an xor comparotor. Claptrap. Seriously who the hell cares, I have used webforms since day one and have never had these issues. Complex event lifecycle? Uh you cant be serious. People have been banging on about the next big thing in software design every couple of years only to see it end up on the heap 5 minutes later with the geek brigade coming out with all sorts of retrospective rubbish. Its there to do a job, do you really think your customers give a crap whether its webforms or MVC? Seriously, get the job done and done quickly architectural hogwash is irrelavent and for the realm of geeks, you can expect at bests your apps to last 5 years so really what the heck does it matter. Your main concern should be ease of maintenance even if that causes a microsecond of delay in rendering a page or a little bloat here and there.......sheeesh.
Reply
Job could be done using any tools. But some tools help and guard developer towards good style, while some fight against. Web Forms belong to that latest category. A lot of unnecessary stuff which stands on the way, absolutely artificial event model, which has nothing to do with actual HTTP requests / responses. Chaos of code-behind pages and typical messy mix of presentation logic, business, and database access logic - which was promoted by Microsoft examples do not help further maintenance at all.
When I was maintaining an old classic ASP code and developing new modules using Web Forms, sometimes it felt more natural to use VbScript of classic ASP pages than to program Web Forms - at least classic ASP didn't dictate logic. To me, Web Forms is failed experiment. That's why more companies / developers move away of it, towards ASP.NET MVC and/or heavier client logic with more Ajax, JavaScript MVC libraries, SPAs, etc - with .NET only used to develop Web Services connecting to databases. Here's where .NET / C# excels and feels natural.
Reply
arabellaanwen's avatar

arabellaanwen · 586 weeks ago

This coders involving ASP. NET could not get envisioned that will programmed looking at would certainly turn into an extremely essential component of software package improvement. Certainly, the particular solidly put together construction they made is improper for system looking at. Incorporation looking at could be a undertaking, too. ASP. NET offers kept switching.
aywebtech.com
Reply
They are specially designed to work with the web form pages. Most of the we server controls inherit from the base class. Yes the state weight generally can slower the response time as and i have faced the same kind of problem with many sites, some times an error message appears like limited bandwidth. I never knew all these only because of those asp.net web forms. Such a knowledgeable post much obliged by this.
http://www.torontowebdesign.company/
Reply
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
Advanced Java online course
Salesforce online course
Reply
I have visited this blog the first time and I got a lot of informative data from here which is quite helpful for me indeed.
Docker online training
Docker certification training
Reply

Comments by