James Higgs posted an interesting rant here on the Postback and Viewstate mechanism in ASP.NET, saying they can turn an application into a nightmare to maintain.

While I'm not sure I'd agree that I would never use them (I certainly have and probably end up doing it again because I'm a lazy bastard), James makes some really strong points against both mechanisms, and I do tend to agree (in principle at least) with most of them. They certainly reflect on things that bothered me about the ASP.NET execution model since the beginning:

  • The core foundation in ASP.NET is really strong, and way cool: IHttpHandler's, HttpModules and so on are really powerful mechanisms.
  • ASP.NET by default is totally built around post-backs, which are really annoying for navigation. This improved somewhat in v2.0, but the model makes things that were really easy in old ASP (yuck, who would've thought I'd be saying that!) because its model reflected fairly closely the GET/POST paradigm inherent to HTTP, and allowed you good control as to where to use each one. By contrast, ASP.NET pretty much expects you to use POST 99% of the time, with the implications:
    • Bookmarking can be made pretty impossible in some scenarios if you're not careful
    • You can end up with a lot of useless redirects which could've simply being done by taking the user to a different page directly from the browser (again, somewhat improved in v2.0)
    • Back/Forward buttons don't always work as you intended them
    • Link controls that use Javascript and post-backs for navigation. Who the heck came up with such a crappy idea? They also completely screw the navigation experience by making it impossible to open the link in a new tab/window.
  • Viewstate... well, is there anything good to say on it?

The good part about all of this is that ASP.NET continues to improve, and certainly there are a lot of good things in v2.0, and I'm hopeful yet about what the next versions will bring to the table on these fronts.

Tomas Restrepo

Software developer located in Colombia.