Slashdot Mirror


The ASP.NET Code Behind Whitehouse.gov

An anonymous reader writes "The author looks at the markup for the new whitehouse.gov site, launched today. It uses ASP.NET and various JavaScript libraries. It suffers from various inefficiencies, most easily remedied. Check the images and techniques used to build the site front-end."

27 of 143 comments (clear)

  1. Maybe we can by AKAImBatman · · Score: 3, Insightful

    The whitespace.gov site has lots of whitespace characters.

    Hmm... Freudian slip? FWIW, most of the whitespace is probably generated by the ASP technology they used. Spots where code goes can often generate unexpected whitespace. It's just a side effect of using scriptlet-type technologies.

    Don't get me started on the "correct" way to write ASP. The tag-substitution gobbldy-gook encourages all kinds of bad page-development practices. The request-time attributes + templating taglibs seen in JSP provide a much cleaner separation between logic and HTML.

    The whitehouse.gov site uses more GIFs than PNGs.

    Ouch. Welcome back to 1996. Web developers looking for the smallest file size really need to learn that there is such a thing as palletized PNGs. They're even smaller than GIFs, even.

    The whitehouse.gov site uses heavy JPG compression.

    This is one place where my reaction is "BFD". As long as it looks acceptable under most circumstances, the people with the carefully color calibrated monitors (*cough*yeslikeme*cough*) can suffer a bit. Heck, half the JPGs on the internet look like garbage, so I'm not too worried about artifacting in the gradients.

    The whitehouse.gov site uses IIS 6.0. The whitehouse.gov site uses ASP.NET 2.0.

    Can we choose the right technologies for a website? No we can't! Thankfully, the President isn't hired to choose the best technology to run his website. ;-)

    1. Re:Maybe we can by zoips · · Score: 2, Insightful

      The request-time attributes + templating taglibs seen in JSP provide a much cleaner separation between logic and HTML.

      Wait, are you serious? JSP is no better than classic ASP; it's arguably quite a bit worse than classic ASP since it isn't language agnostic. JSP is a defunct and outstandingly annoying technology to work with that encourages all sorts of bad habits.

      You might consider checking out Tapestry 5 for something a little more this century.

    2. Re:Maybe we can by AKAImBatman · · Score: 2, Insightful

      JSP is no better than classic ASP; it's arguably quite a bit worse than classic ASP since it isn't language agnostic.

      Language agnostic is pointless when you're not writing code. Correctly written JSP 2.0 files should have no scriptlets in the pages. All the code should be in behind-the-scenes APIs or in parent servlets that use the page for rendering. The JSP solution is far more flexible than the ASP page-backing code files solution, and generally encourages better written code. Looking at ASP.NET pages that reference tags by IDs makes me want to tear my hair out in frustration. ("NO! You do NOT make six instances of the same tag so you can populate them in the page-backing code file! Arrrgghhh!!!")

      On a broader note, .NET's language agnosticism is a farce. You can have any color you want (slate, charcoal, basalt, jet, etc.) as long as it's black. There are no real differences between the languages. They have all been modified to fit the C# mold.

      JSP is a defunct and outstandingly annoying technology to work with that encourages all sorts of bad habits.

      Whatever helps you make it through the day. I've worked with ASP.NET long enough to know that a bit of reality disconnect makes the pain a little more bearable. ;-)

    3. Re:Maybe we can by AKAImBatman · · Score: 2, Insightful

      That "gobbldy-gook" generates valid XHTML, if you tell it to.

      So does every other page templating technology known to man. I can do it in ColdFusion if you ask me to. That doesn't make ColdFusion a particularly good language for scalable site development. Nor does it make ASP.NET anything special. And if I never see more code like this, it will be too soon:

      Featured1.Attributes.Add(...);
      Featured2.Attributes.Add(...);
      Featured3.Attributes.Add(...);
      Featured4.Attributes.Add(...);
      Featured5.Attributes.Add(...);
      Featured6.Attributes.Add(...);

      *sigh*

      Bwahaha... sorry. There are better templating engines than ASP.NET 2.0, but JSP is not one of them - not in a million years.

      Because ASP.NET can output XHTML code? Listen, I've looked at nearly every template language and framework on the market. 90% of them result in coding one's self into a corner. JSP may be simple, but that's it's strength, not its weakness. Especially when you break up your JSP code into smaller pieces and use a higher level abstraction at the servlet level to produce more maintainable code.

    4. Re:Maybe we can by shutdown+-p+now · · Score: 2, Interesting

      On a broader note, .NET's language agnosticism is a farce. You can have any color you want (slate, charcoal, basalt, jet, etc.) as long as it's black. There are no real differences between the languages. They have all been modified to fit the C# mold

      This isn't entirely true. For example, you can have normal ISO C++ compile into pure MSIL - VC++ does that (if you use /clr:pure). When you look at the features the runtime provides, it's pretty obvious: it has raw data and function pointers, arbitrary-layout structs (this means you can also do unions), and manual stack memory allocation. With that, you can implement virtually any language you want.

      Where the problems begin is with the CLR object model. Yes, that one is quite specific, and any language that wants to deal with it (you don't have to, but you lose the class libraries...) has to support it. Note that "support" still doesn't mean "require" - for example, C++/CLI adds the constructs needed both to create and to use classes compiant with the CLR object model, but it is entirely possible to only use them to interoperate with the standard .NET class library, and write the rest of your code in good old ISO C++, using STL and Boost. And yet, your whole app still runs on CLR, including the C++/STL/Boost bits.

      Then of course there is F# (though I guess you can still find some similarity to C# there - but not that much), or, heck, Eiffel and IronPython and Common Larceny - all pure .NET implementations. Will you say that they all also "fit the C# mold"?

    5. Re:Maybe we can by Xest · · Score: 4, Informative

      Whilst I'm a fan of PHP myself, I have to say the new ASP.NET MVC framework is rather good.

      It really does beat hands down anything in the PHP world in terms of how quickly you can get something up whilst maintaining quality. I'd argue partly this is because of the Visual Studio integration and the power of Visual Studio to start with.

      I wouldn't ever build a live app. in web forms, but I could be pretty tempted with the new MVC framework I have to admit. The various PHP frameworks out there that perform a similar task such as CakePHP could learn a lot from it in terms of how quickly you can build with it without the usual sacrifice of quality of software you get with Microsoft's tools (again, web forms for example).

      Of course, the thing is as well, the Microsoft platform is slowly getting better, Windows Server 2008 and IIS 7 really aren't that bad, performance isn't too much different to Apache/PHP now and security since .NET is much improved. Of course, Apache was always pretty good so to say IIS is improving doesn't mean much in that context but certainly combined with .NET MVC I think the whole LAMP platform needs to watch out. The various PHP frameworks like Cake could do things such as dropping the stupid cake bake crap that fails half the time on Windows and is pretty much undocumented (It has one page in the docs that don't explain much beyond what it's for). In contrast Symfony is absolutely fantastic on documentation and so is Zend, but it's still much more hassle, and there's still many more security pitfalls you have to keep an eye on vs. ASP.NET MVC.

      I'd probably like Java, but I've never used it professionally, only academically so can't compare with that. At the end of the day though, my point is that with ASP.NET MVC I can build a high quality site much more quickly and with much greater confidence than I can with any PHP framework right now.

  2. whitehouse.gov Blog? by troll8901 · · Score: 2, Interesting

    Not to mention ...

    TUE, JANUARY 20, 12:01 PM EST
    Change has come to WhiteHouse.gov
    The first post on WhiteHouse.gov.

    A "first post"?

  3. This page is a way by Nimey · · Score: 4, Insightful

    for the author to show his superiority to the Internet. None of what he cites really matters.

    --
    Hail Eris, full of mischief...

    E pluribus sanguinem
    1. Re:This page is a way by ergo98 · · Score: 3, Interesting

      for the author to show his superiority to the Internet. None of what he cites really matters.

      True enough. Indeed, the page in question actually validates as XHTML Transitional which is something that is remarkably rare and shows a concern for craftsmanship.

  4. Helpful advice?? by biocute · · Score: 4, Insightful

    Many developers use the JQuery from Google's servers for improved performance and lower latency.

    Is this guy serious? Advising Whitehouse.gov to use a remote server to serve javascripts?

    1. Re:Helpful advice?? by c_g_hills · · Score: 4, Insightful

      Who said anything about hacking? It's entirely feasible that they would change the script they serve up themselves. It would allow Google to track all visitors to the site who have javascript enabled, a possible privacy violation.

  5. well at least it's not... by Cyko_01 · · Score: 4, Insightful

    ...flash based!

  6. Is it Valid? by gloryhallelujah · · Score: 2, Informative
    --
    The Turing test cuts both ways
    1. Re:Is it Valid? by Dotren · · Score: 2, Insightful
      Looks to me like a lot of those CSS results are due to trying to make it cross-browser compatible. Looks like they went pretty far back too... some of those tags have been depreciated since Firefox 0.9.

      I never really did the color comparison/validations on my pages although I can see how handy that information could be and I bet its pretty easily remedied.

      What I am surprised about is that you mentioned its valid HTML. The article mentions the site uses .Net 2.0... its been my experience that most, if not all, of the pre-built controls they offer end up compiling into invalid code. I've heard you can change this by re-writing parts of the controls and if they did that to produce valid HTML then I'm impressed.

  7. New robots.txt file by Cyclopedian · · Score: 5, Interesting

    The switchover of the whitehouse.gov site also meant that the robots.txt file has changed. From around 2400 lines to just 2 lines: http://www.kottke.org/09/01/the-countrys-new-robotstxt-file

    1. Re:New robots.txt file by The+Bungi · · Score: 2, Informative

      Obviously because of growth through the years. The same file in 2001 was pretty much empty as well.

    2. Re:New robots.txt file by hansamurai · · Score: 4, Funny

      Disallow: /firstlady/behindthescenes/text

      Can't wait to crawl that one.

    3. Re:New robots.txt file by kenj0418 · · Score: 2, Funny

      That's only fair. He's the president for all the robot-american's also. They should be able to access the site as well.

      And if you don't agree, you can "kiss my shiny metal ass."

  8. Campaign servers ran open source by rwa2 · · Score: 4, Informative

    http://www.linuxjournal.com/content/open-source-force-behind-obama-campaign

    My take is that the whitehouse.gov servers are run by the government and have to conform to DoD security guidelines, which have only relatively recently included Linux configurations for certain commercial distributions such as Redhat. So they probably don't have the freedom to redo the servers with whatever they could cobble together with talented volunteers for the campaign.

    Anyway, we'll eventually see whether all this talk of change only runs skin deep.

  9. I'm an ASP.NET developer... by Junior+J.+Junior+III · · Score: 2, Insightful

    ...and, admittedly, a pretty sucky one. I figured out html on my own and it's not the main thing I do at work, so I never learned how to do things "the right way", and neither did any of my co-workers, for the most part.

    I do want to do things the right way, so I read articles like the one linked to in this story with interest. However, I get NOTHING out of them when they're written like this:

    The whitehouse.gov site uses ASP.NET 2.0. The HTTP header that identifies the software says "X-Aspnet-Version: 2.0.50727". There is a way for this header to be removed, which saves about 30 bytes of bandwidth on every response. [Search for 'X-Aspnet-Version']

    It's annoying to read someone going off about inefficient practices without telling you how to do it better.

    "There is a way?" Nice. Thanks for sharing.

    (Yes, the "[Search for 'X-Aspnet-Version']" is dead text, not a link to anything...)

    It's like this with virtually every other tech problem I've ever tried to research... Zillions of pages of people complaining about a problem, suggesting fixes, or claiming that something they did fixed the problem, and very little in the way of actual, detailed information about the fix, how and why it worked, and what exactly the problem was that it solved.

    --
    You see? You see? Your stupid minds! Stupid! Stupid!
    1. Re:I'm an ASP.NET developer... by AKAImBatman · · Score: 2, Informative

      First hit on Google. Remember to search only the "X-Aspnet-Version" (remove the quotes) part of that text. BTW, as efficiencies go, this is a pretty minor one. It matters for a site like whitehouse.gov because they're likely to get a few million visits per day. (At least in the short term.) Very few websites have that problem, so I wouldn't worry too much about it. :-)

  10. Re:PNG/GIF i'll forgive by Mad+Merlin · · Score: 2, Insightful

    The PNG hack for IE6 has some rather fatal drawbacks, particularly if you want to use it to replace background images instead of just regular <img>s. The most obvious issue is the z-index one, in that the PNG hacked PNG is rendered on a layer on top of the canvas, for which no events (including clicks) will pass through, unless you throw in a lot more hacks and you're really lucky. The other more insidious problem is that any element with a PNG hacked PNG must have layout, meaning it's almost guaranteed to have nasty side effects on any non-trivial page. I don't really care about IE6, but out of curiosity I tried applying the PNG hack to the gameboxes in Game!, and quickly scrapped the idea after finding several major issues due to the required hasLayout hack.

    PNG8 is an interesting aside, but only marginally better than just serving GIFs to IE6.

  11. Engineering nerds, this is an example! by Anonymous Coward · · Score: 5, Insightful

    You will encounter this sometimes in your life, and you better get used to it. Sometimes, believe it or not, things are done simply because they need to be done.

    They don't spend a lot of time laboring over every little detail, they have a list of tasks and a deadline and they do their best to meet the deadline.

    They anticipate that nerds who nitpick Battlestar Galactica episode continuity errors will likely come in and stroke their butter soaked neck beards and chortle about how this or that could be done better to achieve 5% faster page loads, or allow for translation into Swahili.

    But, they get paid either way and in the grand scheme of things trying to impress anyone on Slashdot is probably pretty low on anyone's to-do list.

    As someone who's argued with people about vi vs. emacs in the past, I can honestly say you guys have reached a new low both in wasting time, having no worthwhile point, and being worthless slashdot editors. The trifecta.

  12. What is this ignorance? by KlomDark · · Score: 4, Informative

    I just love when people who know nothing about ASP.NET attempt to critique things:

    The whitehouse.gov site has long ASP.NET IDs. There are many elements on the page that have very long IDs, which are mainly a waste of bandwidth usually. They could be easily removed on the server side.

    <a id="ctl09_rptNavigation_ctl00_rptNavigationItems_ctl01_hlSubNav"...

    Sorry bud, they can't really be removed on the server side - these are controls embedded in controls embedded in controls. Maybe a slight shaving of rptNavigationItems down to rptNavItms or something, but the long name is to be able to reference the embedded controls.

    Please try again...

  13. Re:The fact that he uses them makes them the best. by MindStalker · · Score: 3, Insightful

    Technically its the same server and software that was on whitehouse.gov yesterday under the Bush Administration. Like the Defense Secretary, keeping the stuff that works and would be a hassle to change around for right now.

  14. Pick the low hanging fruit. by mr+sharpoblunto · · Score: 3, Interesting
    Most of the optimization suggestions in TFA are going to offer no real performance benefit. With gzip on, whitespace, long ID's & viewstate make pretty much no impact on the final page weight, but doing these "optimizations" is going to make your page a hell of a lot harder to maintain. Don't believe me, go to webpagetest.org and have a look, HTML accounts for only around 5% of the final page size. The best thing these guys could do to optimize the site would be to
    • combine the css and javascript files.
    • minify the javascript (as it is its taking up around 20% of the page weight)
    • perform more aggressive css spriting of the gif and jpeg images to slash the request count further.
    • remove ETag headers and add far future expiry headers to the images to speed up repeat page views and cut down on 304 responses from the server.

    Who cares about a 30 byte http header when your page is over 800k and ~45 requests, there's plenty of low hanging fruit to pick first. Interesting thing is in the post above a tool called the rpo is mentioned, it seems to do most of the important optimizations automatically.

  15. Anyone try a DNS lookup? by iabervon · · Score: 2, Informative

    $ host www.whitehouse.gov
    www.whitehouse.gov is an alias for www.whitehouse.gov.edgekey.net.
    www.whitehouse.gov.edgekey.net is an alias for e2561.b.akamaiedge.net.

    Reducing their bandwidth and server load is just not a big deal. (See Akamai and note that the whole site takes the path that the "image" request takes in that diagram.)