Dot Net Tricks

Articles about .NET, ASP.NET, C#, Object Oriented Programming and Agile Methodologies
Welcome to Dot Net Tricks Sign in | Join | Help
in Search

Software Theosophy

ASP.NET Sucks and It DOES Matter

This is partially in response to this somewhat infamous article by Jeff Atwood:

http://www.codinghorror.com/blog/archives/001119.html

In this Jeff mentions that although PHP as a language and platform sucks, it doesn’t matter.  Its low barrier to entry has allowed PHP to become the defacto standard for major and minor websites all over the internet, as well as many decent software packages, such as shopping carts and Content Management Systems.  The fact is there is a lot of great software written in PHP, despite the language’s overall suckiness. 

With ASP.NET, my web framework of choice, things are a little different.  Sadly, I must confess that ASP.NET also sucks, although in a different way, and in my opinion it does matter.  This limits the number of decent free and even commercial software packages.  Trying to find a decent, user friendly, engaging software package such as a shopping cart or CMS in ASP.NET is difficult at best, especially if you want one for free.  ASP.NET may hold a place of distinction among enterprise applications and large corporate websites, but in the world of social networking sites, shopping carts and the like it’s virtually a no show.  On the enterprise ASP.NET has done rather well, competing with the other heavyweight: Java.  But for basic websites, it well….sucks.  At the web shop I work at now, I had almost come to the conclusion that asp.net is the wrong choice of technology for us or at least for the majority of our small business customers.   Our sites are too small, the work and overhead of ASP.NET make development too slow for these simple projects and the lack of good software packages such as shopping carts and Content Management Systems put us behind our competition.

Take for example, our CMS.  We’re using arguably one of the best commercial CMS applications on the market for asp.net and still the software is complicated to install, upgrade, extend, style and manage.  Our clients have issues as well.  Drag and drop is supposed to work, but it doesn’t in certain circumstances.  The WYSIWYG editor adds extra span tags or shifts formatting and spacing around seemingly at a whim.  The user experience could be a lot better and faster.  I can feel the weight of viewstate with every click in that CMS.  In the shopping cart arena, things are nearly as bad.

So why is it that PHP sucks and yet there are tons of websites and really good software packages for it, many of them for free?  With ASP.NET, it’s difficult to find good applications, especially among the open source community.

First, there is the overall learning curve of ASP.NET.  I’ve already documented a lot of the ways in which ASP.NET sucks so I won’t go into too much of that here.   Search google for “ASP.NET sucks” and you’ll get a lot of really valid points from people that apparently are a lot smarter or less stubborn than I am, because they gave up on it back in version 1.1.  Suffice it to say, ASP.NET development is complicated and much harder than it needs to be.  But it goes beyond that.  Its also a very difficult paradigm to understand for anyone familiar with other web technologies: html, css, flash, javascript, php, java/jsp, coldfusion or even classic asp. ASP.NET looks, feels and acts different than almost any other server-side web technology, and integrates poorly with the client technologies.   ASP.NET is almost entirely ignored by web designers.  The barrier to entry for the average web developer or designer means that it has not become the standard it could be, at least for the average website market.   I can sum up this barrier to entry in two words: “Web Forms”. 

The Web Forms paradigm that ASP.NET is based on is both a blessing and a curse.  On the enterprise where ASP.NET does well, web forms is a blessing, at least historically.  This is because it mimics a forms-based, stateful, event-driven technology such as win forms or even java desktop applications.  The web forms abstraction makes web development seem similar to desktop development.  Where this created hurdles for existing web designers and developers trying to learn ASP.NET, it lowered the barrier of entry for existing desktop programmers doing Visual Basic, Java, Visual C++ and heck, even Microsoft Access.  In addition, the object-orientation of the .NET Framework and Microsoft’s two revered languages, C# and Visual Basic.NET, was attractive to programmers coming from a Java, C++ or Visual Basic 6 background.  .NET has a simpler class library and structure than COM or VB did, and is familiar to the point of Déjà vu for java developers.

But for your average web designer, who may be an Html, CSS and Javascript guru, ASP.NET is an anathema.  Take for example the ASP.NET control hierarchy.  Using server controls in ASP.NET means that Html is generated in a way that interface designers can’t control very well.  Sure they can slap a “CssClass” attribute on most controls but the actual Html generated is hidden from them and can throw a lot surprises their way.  Worst still, this generated code messes with the Html tag hierarchy that a lot of designers rely on in their CSS and Javascript.  Usually designers will get used to the built in server controls and figure out their idiosyncrasies, but as soon as you throw in a 3rd party control, it’s a whole new ball game with a new set of rules, quirks and surprises.  We’ve gone thru a lot of this trying to skin third party controls and both myself and our interface guys have pulled our hair out trying to get the CSS “just right” in order to properly style a control that spits out mountains of Html and javascript and CSS of its own that we can’t see until runtime and which has a lot of dependencies on certain CSS classes, Ids and tags.  Its just TOO HARD.

But the cardinal sin of ASP.NET is how it deals with the all-important Html ID attribute.  I can’t say this strong enough, so forgive my crudeness, but ASP.NET RAPES the ID attribute.  At my second ASP.NET job, my manager was constantly asking us to do challenging and interesting user interface tweaks using JavaScript, and every time he did I just groaned inwardly in a way that I never had to with Coldfusion or classic ASP.  ASP.NET in its effort to emulate that stateful, event driven, desktop paradigm, goes and wreaks havoc with the all the server controls’ ID attributes.  ASP.NET dynamically changes the ID attributes of any Html that is generated by a server control.  So you have to ask for the generated ID through server-side code.  The ID can’t just be hardcoded because it may change at runtime depending on the hierarchy.   So what was once a simple integration between Javascript and server-generated Html now requires the developer to expose the control’s ClientID to javascript thru nonsense like this:

<%# this.textBox1.ClientID %>

Which also requires a call to Databind() somewhere because using Response.Write or <%= %> causes the infamous “control collection could not be modified because the control contains code blocks” exception. 

In addition, web designers also rely very, very heavily on the ID attribute and tag hierarchy for coding CSS.  So when the tag hierarchy and IDs either are not known or they change for the same reason, this breaks the designers CSS and causes them a lot of headaches to get them working.  Unfortunately, ASP.NET does both, so it makes styling a page like trying to hit a moving target. 

In other words, it now requires a programmer who remembers all these ASP.NET quirks to get the user interface working, and looking, right.

Finally, ASP.NET’s web form model adds a huge learning curve from those coming from other server-side technologies.  PHP, Classic ASP, Ruby-on-Rails, Coldfusion, JSP  (perhaps excluding Java-server faces, which I know almost nothing about) all have similar ways of doing something.  You markup an Html page and embed server side code in it, usually using some kind of separate tag syntax.  Web Forms don’t really work this way and Microsoft doesn’t really encourage it.  What they were trying to do was noble—they were trying to separate markup (html) from presentation logic (C#, Java, VB, etc.)  Whereas the other technologies mix them together, Microsoft was rightly trying to separate them out.  And I have to admit that a well designed aspx page and its code-behind is a beautiful thing to behold.  The aspx contains only Html and Server-Control tags, and the code-behind contains only C#. 

But consider this, let’s say I have a  grid on the page full of tabular data containing customers and their current balance.   I want the Customers being displayed on this grid that have a balance greater than zero to have their balance highlighted in red.  What is involved in accomplishing this relatively simple presentation task?  Just breeze thru the following steps…

  1. Wire up the GridView’s ItemRowBound event to an event handling method.
  2. In the event handling method, check that the current row’s data item isn’t null (this avoid exceptions because the headers and footers don’t have data associated with them.)
  3. Create a local variable for the Customer data, like a Customer object, dataset, etc. 
  4. Now cast the row’s data item to whatever you’re binding to—the Customer object, DataRow, etc.
  5. Oh, wait if you’re binding to a dataset, you have to cast the row’s data item to a DataRowView, not a DataRow.  After 6 years of ASP.NET, I still don’t know why that’s necessary. 
  6. Now that you have your data, check the customer’s balance to see if its greater than zero.
  7. Now use FindControl on the current row of the GridView to find the control  (label, textbox, etc.) that contains the balance, or use the row’s Cells properties if there’s not a control nested in there.  If you have a control, you also have to cast it to a control.

Now, I’m not being completely fair, because part of the work above is not the fault of ASP.NET, it’s the fault of a strongly typed language with all its casting necessity.  But much of the casting would be unnecessary even in JSPs which use another strongly typed language. 

When I first was learning asp.net and tried to do the above tasks, I was lost.  My instinct was to start a “for loop” and put in one “if” statement and be done with it, but that was not really feasible with a DataGrid, and probably wouldn’t be recommended by Microsoft or the ASP.NET community.  I had a long learning curve ahead of me.  Now after 6 years of ASP.NET development under my belt, it’s a piece of cake and I do enjoy the separation of concerns.  But I suspect a lot of web programmers coming from other server-side platforms, took a look at all this crazy web forms stuff and swore it off.  Its different, its complicated and it slows down development. 

Which goes back to what spawned this post.  Why is it so many public facing websites are written in PHP, and there are so many great shopping carts, CMS’s and other free software for it?    Why are there so few for ASP.NET?  Its because ASP.NET was designed for desktop programmers and almost completely ignored existing web designers and web developers. For all its flaws, for all its lack of object orientation, its global functions, its quirkiness and ugly syntax, PHP is friendlier to web designers and web developers.  It’s friendlier with CSS, Javascript and by extension, all the cool UI toolkits out there like Dojo, Scriptaculous and Prototype.  This doesn’t make it better, and I’d certainly choose ASP.NET in a heartbeat for a complex, line of business, web application over PHP.  But if you need a small to medium size website up quickly and cheaply, nothing beats PHP and its slew of free, open source, scripts and applications.

I believe there is hope for ASP.NET however.   Ironically, this comes not from some quick and dirty code-generating, drag and drop toolkit that Microsoft is throwing over the wall, but for something that was designed to fix some of the alleged flaws in the web forms model for enterprise development.  Enter the ASP.NET MVC framework. 

According the ASP.NET website, the MVC framework and the design pattern its based upon has the following benefits:

  • It enables you to achieve and maintain a clear separation of concerns
  • It facilitates test driven development (TDD)
  • It provides more control over the URLs you publish in the application and over the HTML that is emitted by the application

The first two bullets will probably not make a blip on the radar of most web designers.  But the last part, about full control of the Html, as well as other deviations from web forms, could actually lower the barrier of entry to ASP.NET development.  MVC styled development isn’t going to muck with my html tags, it’s not going to change the ID attributes, there’s no viewstate, there’s far less reliance on events and controls.  Forms can post anywhere.   You can throw an “if” statement or a “for loop” in the middle of the page to generate Html without it being quite a sacrilege.

So besides solving a lot of the “enterprisey” problems such as better separation of concerns and TDD, it may actually make web development friendlier to web designers and non-ASP.NET web programmers.  Maybe there won’t be an immediate slew of well designed MVC shopping carts and CMS applications, but there might be a renewed interest in the ASP.NET platform from designers.  So in a sense, ASP.NET developers can now get the best of both worlds: Enterprise friendly architecture, and web designer friendly simplicity.  I can get my nice C# objects and the elegance of the .NET framework class library, without dealing with web forms complexity.  There might be hope for ASP.NET yet.

 

 

 

Published Sunday, August 03, 2008 8:13 PM by Fregas
Filed Under: , , ,

Comments

 

ASP.NET MVC Archived Blog Posts, Page 1 said:

August 4, 2008 8:45 AM
 

jrgarcia said:

I agree. I'm really looking forward to testing out the ASP.NET MVC framework. Trying to modify or style some *cough* third-party controls is really beginning to be a pain. Having to guess, try again, guess, try again, etc. until you get it is a nightmare. I love Web Forms due to their ease-of-use (coming from a VB6 Forms background), but for someone who began work in PHP, JSP, etc. this would be an absolute nightmare. I believe you hit the nail on the head.
August 4, 2008 1:10 PM
 

Software Theosophy said:

For the six or seven of you in the world that actually read my blog, you've noticed that i've been pretty...
December 11, 2008 4:58 PM
 

User links about "codinghorror" on iLinkShare said:

April 10, 2009 1:18 AM
 

Websites tagged "dataset" on Postsaver said:

April 30, 2009 6:46 PM
 

Kia Sedona 3 Pt, Optima Alternator Replacement Kia Sedona said:

May 20, 2010 12:45 PM
 

Hyundai Xg350 Full Elantra Touring, Elantra Promo Guaranteed said:

May 20, 2010 2:21 PM
 

Clearance Toshiba Qosmio G25 Av513 Windows Xp Media Center, G25 Promo Reinsurance said:

May 20, 2010 3:47 PM
 

1994 Gmc Jimmy Parts Envoy Xuv, Gmc Feather Finish Part Envoy Xuv said:

May 20, 2010 8:22 PM
 

1966 Corvair Seats, Corvair Parts Air Cooled 4 Door Sedan said:

May 20, 2010 10:25 PM
 

Radiator Warming Hoax 2002 Oldsmobile Alero, Alero Greetings said:

May 20, 2010 10:38 PM
 

Chevrolet Equinox Diagram, Equinox Part Ii Memory Alpha Uss Voyager said:

May 20, 2010 11:11 PM
 

S550 Amg Model Supercharged, E 250 Econoline Club Wagon Used F 350 1995 Ford Crown Victoria said:

May 20, 2010 11:48 PM
 

Buy 300te 1992 Mercedes Coil Spring, 1990 Mercedes Benz 300te Amg Estate said:

May 21, 2010 12:03 AM
 

2007 Chrysler Sebring Bbq, 2005 Sebring Convertible Mpg said:

May 21, 2010 12:10 AM
 

C25 K2500 Pickup Part Wiring Harness, Used Ring And Pinion Gmc K25 K2500 Pickup said:

May 21, 2010 1:12 AM
 

Chevrolet Trailblazer Kofferraum 2002 Audi, 2006 Chevrolet Trailblazer Ss Fuel Economy said:

May 21, 2010 2:46 AM
 

Citizen Skyhawk Canada, 1986 Skyhawk For Sale Buick Lesabre said:

May 21, 2010 3:03 AM
 

Connect Pyranha Fusion Kayaks, Celsior New Reperfusion Injury said:

May 21, 2010 4:41 AM
 

1967 Ford Econoline Minivan For Sale, E 150 Econoline Hide said:

May 21, 2010 2:20 PM
 

Used Mazda Mpv Sale, Bulb Mazda Mpv Headlight Assembly said:

May 21, 2010 2:35 PM
 

Bmw 630csi For Sale, Cheap 630csi Bosch said:

May 21, 2010 3:14 PM
 

Radiator 1999 Mercury Mountaineer L V8 Windshield Wiper Motor, Mountaineer Adoption Available County said:

May 21, 2010 3:41 PM
 

1993 Hyundai Scoupe Parts Headlight Replacement, Xg300 Discount Parts Rear Bumper Cover Hyundai Scoupe said:

May 21, 2010 4:10 PM
 

Vigor Stroller, Vigor Clearance Buy said:

May 21, 2010 4:50 PM
 

Xc90 Headlight Apa, Pre Owned Volvo Xc90 Ma said:

May 21, 2010 7:06 PM
 

Lincoln Navigator Radiator Hose Ehow, 2002 Lincoln Navigator Interior Parts Fog Lights said:

May 21, 2010 9:09 PM
 

1986 Mazda B2000 Firing Order, B2000 Rapidshare said:

May 22, 2010 12:26 AM
 

Cooling System Dodge W150, Casio Paw1500 Combining said:

May 22, 2010 12:59 AM
 

Used 2002 Cadillac Seville 4.6 L 2006, Seville Seats Catera Cadillac Allante said:

May 22, 2010 3:06 AM
 

Gs450h Part Inventory 2010 Lexus Gs, Ford E 450 Super Duty Stripped Chassis Manual Mirror said:

May 22, 2010 3:17 AM
 

C280 Headlight Promo 2007 Mercedes Benz, C280 4matic Mercedes Benz C230 Kompressor said:

May 22, 2010 3:20 AM
 

Rx400h Radiator Inventory Es350 Lexus Rx350, Es350 Part Salvage Popular said:

May 22, 2010 4:05 AM
 

M45 Headlight Bulb Osram Sylvania, Headlight 2004 M45 Infiniti Qx56 said:

May 22, 2010 7:22 AM
 

Women Columbia Titanium Jackets, Titan Promotion Hendersonville said:

May 22, 2010 7:50 AM
 

Brake Light Gmc Typhoon, Typhoon Guide said:

May 22, 2010 11:19 AM
 

22 Caliber Rifles Sale, Gun Caliber Mm 408 Chey Tac said:

May 22, 2010 11:52 AM
 

Canon 450d Battery Charger Digital Rebel Xsi, 620 Pickup Episode Below Door said:

May 22, 2010 1:46 PM
 

Avolar Replacement Dassault Falcon 7x, Ford Falcon Autozone said:

May 22, 2010 2:20 PM
 

Volvo 244 Taxi, Volvo 244 Replacement Catalytic Converter said:

May 22, 2010 2:21 PM
 

01 Cobalt Body Kits, 2008 Cobalt Fuel Economy said:

May 22, 2010 3:25 PM
 

1987 Chrysler Fifth Avenue Parts Rubber Molding, 2006 Signature Chrysler Pacifica Touring said:

May 22, 2010 3:52 PM
 

Download Dart Xp Pro, 1968 Dart 440 said:

May 22, 2010 7:43 PM
 

350sdl Aftermarket Apa C36 Amg, 350sdl Used 1991 Mercedes Benz Fuel Injection Pump said:

May 22, 2010 8:51 PM
 

Aftermarket Mercedes Benz E350 C55 Amg, Used Mercedes Benz C240 C350 Sport C55 Amg said:

May 22, 2010 9:50 PM
 

Cj5a Guide Salvage, Cj5 Removal Hood - 258.1fh.org said:

May 23, 2010 12:08 AM
 

K25 K2500 Country Used Blocks, Acai Berry K25 K2500 Suburban Part - 188.myipgirl.com said:

May 23, 2010 4:36 AM
 

Mitsubishi Expo Oem Position Sensor, Lp Import Export Supplies Ltd Address - 40.akemet.com said:

May 23, 2010 7:30 AM
 

2006 Corvette Used Car Prices, Ls2 Radiator Shroud Chevrolet Corvette - 3.renters.ws said:

May 24, 2010 5:13 AM
 

Gre Practice Questions, Ionquest Ion Chromatography Systems - 126.an74.com said:

May 24, 2010 6:17 AM
 

V1500 Used S15 Jimmy Yukon Xl Gmc Sonoma, V1500 2nd Hand Rambler Fiat - 291.eumreborn.com said:

May 24, 2010 9:51 AM
 

Dvd G550, G55 Amg Specs 2009 Mercedes Benz Sl - 220.cmanager.org said:

May 24, 2010 10:07 AM
 

Bmw 635csi Installation Parts, Headlight Bmw 635csi Parts Catalytic Converter - 338.tgrconversions.com said:

May 24, 2010 10:46 AM
 

Honda Odyssey Digital Clock, Odyssey Books 10 11 - 42.an74.com said:

May 24, 2010 11:29 AM
 

Used Lumina Car Classifieds, 1995 Lumina Review - 88.ja3ra.com said:

May 24, 2010 12:14 PM
 

Last Minute Navigator, 1994 Holiday Rambler Navigator - 3.jeepsunlimted.com said:

May 24, 2010 1:18 PM
 

1986 Chrysler Fifth Avenue For Sale New Yorker Grand Voyager, 350 Fifth Avenue Ny Ny - 13.luna-atra.net said:

May 24, 2010 3:08 PM
 

Volkswagen Eos Aftermarket Accessories, Mr2 Videos Non - 334.rkwrh.com said:

May 24, 2010 3:28 PM
 

Honda Acura 2005 For Sale, 2004 Bmw 325 Xi Acura Tl - 358.jordanbrandallamerican.com said:

May 24, 2010 3:57 PM
 

Aftermarket Truck Ford F100 Parts Cab, Buy Dodge B100 Brake Pads - 163.zapstreaming.com said:

May 24, 2010 6:58 PM
 

Free Optima Nova Font, Nova Ii Headlight Parking Tail Lights - 274.akemet.com said:

May 24, 2010 8:02 PM
 

Ford G1000 Drama Discount, Chevrolet G1000 Series Bulb - 473.eumreborn.com said:

May 25, 2010 12:21 AM
 

Plymouth Grand Voyager Se Timing Belt Replacement, 1971 Plymouth Barracuda Video - 111.tgrconversions.com said:

May 25, 2010 5:23 AM
 

380slc Car Packages, Cheap 380slc Cl55 Amg - 65.defutbolazo.com said:

May 25, 2010 11:53 AM
 

Covers Chevy Cobalt Tail Light, Chevrolet Cobalt Trunk - 191.animejin.com said:

May 25, 2010 3:23 PM
 

Oldsmobile Cutlass Calais Pot, Oldsmobile Cutlass Calais Engines For Sale - 319.jordanbrandallamerican.com said:

May 25, 2010 4:18 PM
 

Sienna Rebuilt Transmissions, Toyota Sienna Coolant Drain Plug - 434.tgrconversions.com said:

May 25, 2010 5:41 PM
 

Cadillac Sts Club, Space Shuttle Sts 128 - 358.unlockiphone30.net said:

May 25, 2010 6:51 PM
 

2005 Equinox Recalls, Equinox Custom Accessories - 257.tgrconversions.com said:

May 25, 2010 7:25 PM
 

Stealth Coolant Call Mitsubishi 3000gt, Dodge Stealth Accessories Mitsubishi 3000gt Power Steering Rack - 471.akemet.com said:

May 25, 2010 8:13 PM
 

740 Supercharger Kit, 1988 Volvo 740 Turbo For Sale - 468.binggreen.com said:

May 25, 2010 9:03 PM
 

Part Golf Exchange My, Part Golf Car Fender Flares - 427.tijuanareader.com said:

May 25, 2010 9:48 PM
 

1997 - 2003 @ 244 Aftermarket Rental, 244 Custom Post - 32.unlockiphone30.net said:

May 30, 2010 10:44 PM
 

1983 - 1994 @ 280sel We Buy Sent, 280se Cheap Used Mercedes - 35.1fh.org said:

May 30, 2010 10:57 PM
 

2009 - 2008 @ Part Coupon Code Toyota Yaris Hatchback, 2008 Yaris Front Wheel Drive - 245.jeepsunlimted.com said:

May 30, 2010 11:06 PM
 

1993 - 1983 @ Hyundai Drum Brake Parts, Model 2006 Hyundai Tiburon Cold Air Intake - 466.eumreborn.com said:

May 31, 2010 3:50 AM
 

1989 - 2008 @ Impulse O2 Deodorant, Isuzu Impulse Replacement Mud Flaps Oxygen Sensor - 175.myipgirl.com said:

May 31, 2010 3:59 AM
 

1981 - 1996 @ Sl2 Exhaust Pipe Saturn Sc2, 1995 Saturn Sc2 Battery Light - 81.jordanbrandallamerican.com said:

May 31, 2010 3:17 PM
 

2008 - 1990 @ Second Hand Silver Shadow Car, Honda Shadow Spirit Horsepower Gsx - 126.eumreborn.com said:

May 31, 2010 3:20 PM
Anonymous comments are disabled

About Fregas

Craig is currently the Lead Developer in Fort Worth, Texas for Enilon Group, a web development firm. He has been programming since 3rd grade (using the Commodoore PET) and professionally for the past 7 years. He has written several articles for ASPToday.com and co-authored the book "Beginning Web Programming using VB.NET and Visual Studio .NET" Currently, his favorite programming language is C#, but he has programmed in Visual Basic, T-SQL, Ruby, ColdFusion, ASP 3.0/VBScript, ASP.NET, Javascript, Java and even Pascal. Besides programming, Craig is best known for his cooking and his somewhat offbeat sense of humor.

This Blog

Post Calendar

<August 2008>
SuMoTuWeThFrSa
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

Syndication

Powered by Community Server, by Telligent Systems