How’s that for an inflammatory title?
Let me prefix this post with a brief disclaimer. I like Microsoft’s .NET platform. C# is a great language to work in, it’s flexible & powerful. Plus, the .NET framework contains some great functionality that makes my job so much easier. In short, C# rocks.
Having said that, I have some issues with ASP.NET. Deane Barker from Gadgetopia has highlighted some of these issues, and while I’m not quite as down on it as he is, I think he makes some good points
ASP.Net is such an abstraction. It’s like one day Bill decided that we all knew too much about how the Web worked, and he needed to invent a framework that changed all the rules and hid all the scary HTTP stuff so that a generation of Web developers that he trained on his stuff exclusively would have a very skewed perspective about how the Web actually worked.
I hope that didn’t sound arrogant, but I do think that if you’ve never done any Web development except ASP.Net using Web Forms, then there’s a lot you missed about Web development.
I think the UpdatePanel released with the ASP.NET AJAX Extensions really demonstrates this issue. The UpdatePanel is really powerful. It allows you to write your code essentially the same as you always have, with a few small modifications. You then just wrap your ASP/HTML controls in an UpdatePanel and hey presto, you’ve got them running as AJAX controls. No page refreshes, no postbacks. Except that last one isn’t true, it just looks true. On each AJAX event (that is, any event that’s wired up in the code behind for a control that’s a trigger for an update panel), the page does a postback. The full page load life-cycle, including the view state. It has to be this way, or how else could you still access all the values and states of the controls in your code behind methods?
This is just the problem, it makes the development of AJAX-type sites too easy. You don’t have to know what’s going on behind the scenes, you don’t have to understand the asynchronous calls made & the HTTP processes going on.
Now, this may not be all that important if you’re on a small site, with very few steps in the page life-cycle implemented, and small view state. But if your site is large and complex, and you have a lot of controls on the page (ie large view state) this becomes a real issue. If you page currently takes a couple of seconds to load, due to complex processing and data connections, then on every AJAX call, this is how long it’s going to take. Obviously you won’t need to wait for the full page render time, but this is not usually the most time-consuming part of the page load process. Also, you should always make sure you don’t double handle stuff by wrapping as much as possible in a if (!IsPostback) block, but if the page is complex, this will still not always be enough.
Continue reading →