Why you should not place your whole site in an UpdatePanel
AJAX, ASP.NET, Performance, UI By Dave Ward on April 23rd, 2008Perhaps due to its ubiquitous presence in web based email services, implementing asynchronous site navigation is frequently a design requirement when building AJAX based sites. Unfortunately, the also ubiquitous UpdatePanel is chosen to accomplish this far too often.
I’d like to take a moment to strongly recommend against doing that.
I’m going to explain what I believe are the three most dangerous drawbacks inherent to UpdatePanel based navigation: Performance degradation, usability concerns, and lack of maintainability.
Note: I would add SEO concerns to the list of drawbacks, but I’m going to assume that anyone who cares about SEO knows better than to use an UpdatePanel for content they wish to be indexed.
Performance degradation (read: obliteration)
As I’ve mentioned in the past, UpdatePanels endanger the performance of your application. While the UpdatePanel does have its place, the underpinning for your entire site’s navigation system is not one of those places. A quick comparison makes this clear.
This is what happens when you use a LinkButton to trigger an UpdatePanel refresh:
- The PageRequestManager catches the event on the client side and runs through its pre-request events, while preparing an XmlHttpRequest object.
- This XHR object makes an HTTP POST request to the server. This request includes every form field on the page, including the entire ViewState (even for areas of the page not being updated).
- ASP.NET creates a new instance of the Page class, using the ViewState and other POST data to restore its state to that of your last postback or partial postback.
- The Page runs through its lifecycle and returns its rendered HTML result to the ASP.NET AJAX framework.
- The ASP.NET AJAX framework parses out the specific HTML section(s) that will be sent back to refresh the UpdatePanel(s) affected by the partial postback.
- This response is combined with other control information, such as JavaScript content registered via the ScriptManager’s various methods, and sent back to the XHR object.
- The PageRequestManger parses the response and updates the DOM to refresh the affected UpdatePanel(s).
- Finally, the browser renders the updated DOM.
Using a traditional HTML <a> link to navigate the browser to a different page:
- The browser makes a simple HTTP GET request to the URL.
- ASP.NET creates a new instance of that Page.
- The Page runs through its lifecycle and returns its rendered HTML.
- The browser receives this HTML and renders it.
As you can see, these two methods of requesting an update are two very different animals. Not only is the partial postback pipeline far more complex, but some of the additional steps are potentially very expensive.
Perceived performance is usually more important than actual performance. The UpdatePanel is not going to bring this to the table.
When considering performance, it’s also important to keep in mind that what seems fast enough in a local development environment may be devastatingly slow when deployed. It is essential that you test your application’s performance over a WAN connection early and often.
Usability? What’s that?
When you choose to discard the browser’s navigation system for one of your own creation, you also discard usability benefits that you might not be aware of. Each individual browser provides progress indication and other subtle cues that your users have spent years becoming accustomed to. Replacing that with a foreign system is jarring and needlessly introduces an artificial learning curve.
Further, you suddenly make yourself responsible for providing accurate progress indication in every browser. When’s the last time you tested your UpdateProgress template on an iPhone? Yeah, me either.
Personally, I make heavy use of the DragAndGo add-on for regular browsing. When I come across a site that won’t allow me to toss its links into tabs this way, I typically won’t spend much of my time fighting with it.
Needless to say, the LinkButton’s __doPostBack href quickly sends me packing.
Who will you find to maintain it? Not me!
Your single, monolithic page will add tremendous maintenance overhead to your entire application. Worse still, many of the problems don’t present immediately, so it’s easy to start down this road and find yourself painted into a corner later.
For just a taste of what you could be in for, consider these potential pitfalls:
- Imagine if every time you made a modification to page A, you had to carefully avoid breaking pages B-Z and then regression test them all.
- Imagine when your designer(s) want to make changes to the site, but its HTML is locked inside this single page structure. That interaction tends to already be painful enough even with a traditional page structure. Complicating it further is going to be a non-starter in just about any organization.
- Imagine trying to work in a multi-developer environment at all.
- If you’re using VSS or TFS for source control, one developer checking out for a minor edit would lock the rest of the team out of the entire presentation layer.
- If you’re using something like SVN, nearly every change to the presentation layer would result in a merge operation, instead of a simple commit.
Once you start thinking about the potential maintenance issues, you can probably think of a dozen more on your own. I won’t belabor the point.
Conclusion
Hopefully, this laundry list of drawbacks will save you from making the mistake of using an UpdatePanel for site navigation. If not, I hope that it has at least raised your awareness about the problems that lie ahead, so that you may prepare for them now.
So how should you do it instead? Iframes. It’s that simple.
Similar posts
What do you think? Your comments are welcomed.
I appreciate all of your comments, questions, and other feedback, but please try to stay on topic. If you have a question unrelated to this post, I recommend posting on the ASP.NET forums. If you post there and then contact me with a link to the post, I'll try to take a look at it for you.
If you're replying to an existing comment, please use the threading feature. To do this, click the "Reply to this comment" link underneath the comment you're replying to.

Comments
You’re right on the money with this one. I will be there NOT maintaining it with you. :)
It seems to me that you are going towards an MVC approach with this one, since you compare an UpdatePanel postback to a href link click. Shouldn’t you compare it to a normal postback?
I have been working (and finished yesterday, go figure) a little Response.Filter that allows the server to only send the diff content from the previous UpdatePanel render, thus achieving compression from 50% to 98%! This would have been impossible with a normal render, since the browser loses any and all information about previous actions.
What I do agree with is that the ViewState is a troublesome thing, moving back and forth from server to client. But for that I use a SessionViewStatePersister. I don’t know whether that presents problems of its own, but it kept the ViewState from my html so far.
And, of course, having an UpdatePanel on the whole single page and juggling with user controls might be a little complicated and a maintainance nightmare, but it does present advantages, especially in an ASP.Net context which already provided the MasterPage and then MasterPages in other MasterPages, proving the pattern is being used a lot.
I totally agree with the usability thing. But what can you do? Browsers and their users have been growing on each other for years, while the UpdatePanel and the ubiquitous Ajax are fairly recent developments. Should we go back to PHP/ASP days and control every single content byte?
Keep in mind that this is specifically regarding site navigation. I wouldn’t suggest using a traditional postback for site navigation any more than using partial postbacks.
There are always exceptions, but you generally shouldn’t find yourself loading every new content page with a POST.
I agree with you on that one, but grudgingly. I kind of like the UpdatePanel and the Ajax update thing, not for performance, but for the feel of it. I always feel I am losing something when I do a normal link transfer. I wish I had a pattern that would allow for both easy navigation and SEO, but also handled everything with Ajax.
I did encounter situations where the UpdatePanel postback was up to two times slower than a normal postback, because of the Internet Explorer local rendering.
I’ve found that combining jquery with a ScriptService is the best way to go. Throw in the new ASP.Net MVC Framework, disregard the Ajax Extensions and AjaxControlToolkit and you’re good to go.
Thanks for the nice article.
Regarding this comment…
“The ASP.NET AJAX framework parses out the specific HTML section(s) that will be sent back to refresh the UpdatePanel(s) affected by the partial postback.”
Q: When, why in Firebug, I see in XHR Response entire page’s HTML content including the VIEWSTATE?
Assuming that I have a label inside the UpdatePanel, when XHR is initiated, entire page’s VIEWSTATE is sent, but in XHR Response in Firebug, I see again the entire page’s VIEWSTATE + HTML content (and not just my label)?
The entire contents of the UpdatePanel will be refreshed during a partial postback, not only the specific elements that have changed. So, you’ll see all of the HTML contained in a refreshing UpdatePanel come back in the response to the XHR.
You’re right about the full ViewState. The ViewState is atomic. So, it must be transmitted in full, up and back down.
Strange… but what I see in the Firebug’s Response tab is the content of the entire page! not just the content of UpdatePanel. What’s the point to sent the HTML content + VIEWSTATE of the entire page, if the callback was initiated only from the UpdatePanel?
Basically what I see when debugging the app using Firebug is that the whole page’s content is submitted and returned!! back when using UpdatePanel, + the VIEWSTATE.
Maybe it’s something wrong with the Firebug :) ?
Make sure you’re looking at the console tab. If you expand a partial postback’s POST entry there, you should see a request that’s very similar to a regular postback and then a response that’s a pipe delimited string intended for the PageRequestManager.
If you’re seeing a response of the entire page’s HTML, you’re seeing a regular postback’s response (or the response from a GET).
I agree with you that updatepanel is not a great solution from a performance og user experience point of view. However, it seem to solve the problem of maintaining a “temporary” version of larger forms while at the same time doing constraint checks in the database. This could of course be handled by a javascript/webmethod combination, but then you loose the advantages of managed code.
On the other hand it does almost take your breath away when you see the complete javascript-json-webmethod combination used to the fullest like the controls from… componentart (I think they’re called). The performance is almost desktop-like but you have to write all your controls in javascript which must take a lot longer to do.
“but you have to write all your controls in javascript which must take a lot longer to do”
Totally agree. The point of Javascript JSON WebMethod is to archive the functionality of true AJAX application, not a simulation like with UpdatePanel :). BUT! And that “BUT” is the cornerstone. It would be a real nightmare to built manually the Javascript AJAX UI library by hand. Everyone I know decided to use Javascript AJAX libraries available now even for free, such as ExtJS, wich is FULL of any UI elements you might ever need to built your app. So what would be the reason for me to choose ASP.NET AJAX via WebServices?
Sorry, achieve, not archive :)