“Dotnet tips, SQL Server tips, Silverlight tips, AJAX tips...”
Read Experts reviews and compare prices to find the right desktop or laptop for you from the huge collection.
If we don’t take care about how we feed our ASP .net pages… we will find that they will tend rapidly to gain too much weight, this can provide us a lot of headaches like:
--> Things go dam slow when moving into production (everything in localhost was running so smoothly…).
--> If you are using Partial Rendering (AJAX), your pages can become “not usable”, final users complaining about this.
--> Your server will have a hard time generating huge pages (I have seen ASP .net with a weight of 1 Mb or even 2 Mb.).
--> You can even flood your intranet network.
Does your web site generates pages that are over 100 K’s… even over 500 K’s… even over 1Mb… oh oh, you are in a trouble, We are going to do:
--> A fast action plan: just performing some small changes we can reduce the size of our page in-between the following range: 5% - 30 % (depends on the content that you are showing).
--> Other measures to reduce the size of the page, they require more work from your side but you can get quite good improvements.
First of all… How can I measure the weight of my page or partials posts? Download Fiddler, it’s a free sniffer that will let you check the size of your site requests / responses.
Ok, now we have the weighing machine, let’s start with the Action Plan:
<system.web> <compilation debug="false">
(*) In your development environment you will need this set to true in order to debug.
(**) A good idea is to make a console application to trim spaces (give a folder, traverse subfolders and remove spaces on aspx, ascx…).
<asp:ContentPlaceHolder runat="server" ID="phSidebar">
<asp:ContentPlaceHolder runat="server" ID="sd">
(***) You will have to perform a find/replace on all the old Id’s in the child pages (well and ensure that nobody had the bad idea of hardcode this ID’s in javascript instead of using CLIENTID).
Now it’s time to upload your site and check with Fiddler the weight difference with your old pages.
Not good enough? Let’s go for plan B (a bit more of work, a bit more of performance):
--> ViewState:Remove the viewstate in your GridView (if possible in your whole page). ASP .net 2.0 incorporates ControlState, this makes easier to remove the viewstate on server controls (e.g. on a readonly GridView , if you remove the ViewState you will be still able to sort and perform paging). Take care with this, test well the controls where you remove the viewstate.
--> DOM: If some of the markup that you are going to show doesn’t need to be posted, just generating them on the client side via javascript.
--> Nonsense listboxes / combo's:Try to avoid having listboxes or other similar controls that hold more than 80 entries, this reduce the usability of the page and increases the weight, you can change it to an AJAX autocomplete extender, … if your client doesn’t approve that just try to generate the items via webservices + javascript.