开发者

Why is performance on a webpage so different between IE and a WebClient? (TREEVIEW!!!)

I've seen some similar posts, but nothing quite like this...

I have a website (Sharepoint). When I access a particular page that has many custom-coded webparts on it, the page takes ~30 seconds to load. I've used Firebug and confirmed that the long load time is the server working (in the "Net" tab the webpage timeline shows ~30 seconds of "waiting"). I'm also sure it's not javascript taking forever as disabling javascript doesn't affect load times.

However, if I use just a stock .net WebClient and access the page, it only takes ~2 seconds to load.

Even weirder is that some clients do perform faster (not what I would expect if it was a server-side issue). But some clients (like IE 8 on XP) just hang until a server-side error occurs.

I also tried disabling cookies, thinking something on creating the cookie was causing a problem, still no luck at getting the page quicker.

I decided to get experimental and used fiddler. If I removed the User Agent string from the header, the results came back pretty quick, however the body of the response was significantly light. I'm too new at web development to understand what this means, though.

I'm relatively confident at this point that it truly is a server-side issue.

If anybody can help or shed some light, it's greatly appreciated.

Update: Alright, after comparing the contents of the two results, one with a user-agent of IE (or anything for that matter) and one without a user-agent in the header there is a very large difference (approx 3 times more content in the user-agent headered file).

The web-parts contain a 开发者_运维技巧large number of System.Web.UI.WebControls.Treeview objects. When the treeview "handle" is clicked, a table is displayed with data. In the results where a user-agent was supplied, these tables are populated with data (and there is quite a bit, this webpart is highly inefficient).

On the page where no user-agent is supplied, all the tags in the tables are replaced with anchors with javascript calls.

So, I think it's clear now that the TreeView control in ASP.NET handles output differently depending on the user-agent in the header.

That being said, it appears (without further investigation) that the javascript I'm seeing injected instead of data is an AJAX call to get the data and display it more "when it's needed", which is great. Assuming this is the case, now I just need to know how to tell the TreeView control to do this all the time (I do have access to the source code).

Final Update: After some more intensive debugging and proformance profiling I've come to the conclusion that between the fairly sizeable amounts of data and the incredibly bad performance of the ASP.NET TreeView object, I'm gutting that in favor of a Telerik Grid control. I was hoping I could just tweak a few things but the more I looked into it the more I found that the TreeView just isn't very efficient.

Thank you everybody for your help.


The Sharepoint page is probably browser-sniffing the User-Agent, and performing expensive operations for supported browsers.


I would guess that SP is looking at the user-agent string and doing additional loading if certain parts are present. The other thing to check is to see if JS is being sent down (for the web-client version) and if there are more round-trips with IE than with the other clients.

If I remember correctly (been a while) for IE identifying agents SP will send additional client side javascript to handle interactions with forms and accessing things like office and performing version control. I am not sure if that's still true or not.

Its worth using fiddler to compare two or three runs between your webclient, IE and say Firefox to see the differences. You can also copy your user agent string from IE and use it in your webclient and alternate browser runs to see if the behavior is purely from the user agent string.


This is a bad question, but are you sure you're measuring just the body html load time? The browser is loading the html page AND all of its resources: css, javascript and images. The WebClient is only loading the html page as it doesn't - and can't - parse the html.

-Oisin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜