A Programmer's Dream

Web Applications: One Page or Multiple Pages?

Posted by Stephen Wrighton on 29 Dec 2006

ASP.Net is a very powerful programming context, and prior to my introduction to it when I got my job, I was happily a PHP-man.

Frankly, I love the power which ASP.Net provides to programmers developing web applications. The PostBack model, though it can be duplicated in PHP and classic ASP, is a wonderful thing. And it led to some interesting ideas on developing web applications.

Some backstory first. The first ASP.Net site I built was a massive thing, there were three programmers working on it, and we had a 100-odd page design document. This site contained 8 "master" pages, plus another 6 in the administration section. Each "master" page utilized a number of user controls, some shared, others specific to a sub-section.

The next major web application I worked on, I had a bit more hand in designing, and we had a single ASPX page, with everything else user controls. This web application builds documents (and is in use, and still under active development today). And by the time we added in the third document type, the limitations of a single web page became obvious as under a security certificate, there was too much data being passed down the pipe due to all those user controls.

We're talking nearly a meg of data just from the ViewState.

Various scrambling to resolve the issue presented us with a quick-dirty fix so we could deploy the document type in question, and lead me deep into the inner workings of ASP.Net to try to find a more permanent solution. I did find one, and it works beautifully - but that's a story for another day.

While rebuilding my personal website (http://www.krashpad.com), I utilized the same concept for a website. A single page - where content is flipped in and out of controls based on postbacks. In other words, if you click the Archive button, my custom ContentDisplay control goes away, and my custom ArchiveDisplay control appears.

It's great, beautiful. Wonderful from a programmer's POV. Everything I expected and more!

And an utter failure.

Why is it an utter failure? The answer is: because it is a single page, driven entirely by postbacks.

Yes, the very thing I set out to accomplish with the site is the reason it fails so spectacularly. People can not link directly to content. People can not link directly to the Archive. To do anything, you have to go to the main page and perform some combination of clicking on LinkButtons.

Needless to say, I will be fixing it. And I guess the point of this is just to make sure that beautiful programming ideas fit the type of web application you're building before implementing them. While the single web-page concept is great for a web application which builds documents based on user input - it fails utterly as a concept for a content-driven website.

Tweet me @kidananubix if you like this post.

Tweet