Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

A way to improve performance of your Web Application significantly

, 1 May 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
A way to improve performance of your Web Application significantly

For the last few days, I was working on performance improvement of one of my Web applications. I analysed my application in various ways. I also used different profilers and did profiling for my application using several profilers like Ants, .NET profiler, etc. During analysis, I found a few problems that we rectified but got no visible improvement.

Later I thought, my server side code is good enough, but still it's taking time to download the page. Although we are already using IIS compression to reduce the page size, still Page was taking a good amount of time to download.

I posted a blog to enable IIS compression.

Actually, my application is a RIA application and we are using myriad ajaxtoolkit controls in our application. I analysed my application using firebug and there are a lot of scriptresource.axd and webresource.axd files getting downloaded.

So I thought if we can combine these files into a single one, that will be a great performance application boost for our application.

First, I tried doing it by myself. Later, I found ASP.NET itself provides a way to combine these axd files. You just need to have .NET 3.5 SP1.

So if you are using framework version 3.5, upgrade it to SP1 and enjoy this feature.

I have created a small sample and will show you with the help of it.

So in my sample application, I have a Calender extender. Let's see how many requests are there using firebug.

Requests of a Web Page

We can see currently there are 14 requests on every PageLoad. We can reduce the number of requests.

So to use this, first you need to download a ScriptReferenceProfiler. You can download it from here.

Now add the reference in your project and add the profile in your page.

First register it as:

<%@ Register Assembly="ScriptReferenceProfiler" Namespace="ScriptReferenceProfiler"
    TagPrefix="cc2" %>

and add it as a control like:

<cc2:ScriptReferenceProfiler ID="ScriptReferenceProfiler1" runat="server" >
</cc2:ScriptReferenceProfiler>

Now when you run your application, you will see the page.

Now copy all the links and put it in the CompositSctript tag as:

<asp:ScriptManager ID="ScriptManager1" runat="server">
            <CompositeScript>
                <Scripts>
                    <asp:ScriptReference name="MicrosoftAjax.js"/>
	                <asp:ScriptReference name="MicrosoftAjaxWebForms.js"/>
	                <asp:ScriptReference name="AjaxControlToolkit.Common.Common.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Common.DateTime.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Compat.Timer.Timer.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Animation.Animations.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Animation.AnimationBehavior.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.PopupExtender.PopupBehavior.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Common.Threading.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Calendar.CalendarBehavior.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
                </Scripts>
            </CompositeScript>
        </asp:ScriptManager>

Now let's run the Application. Let's check the firebug.

Combined requests

Here we can see the number has significantly reduced. It’s just 4.

But this is a sample and it's working fine. But when you try in your actual application, you might face several issues.
I faced one issue while using with my Live applications.

Issue: The resource URL cannot be longer than 1024 characters. If using a CompositeScriptReference, reduce the number of ScriptReferences it contains, or combine them into a single static file and set the Path property to the location of it.
So first, I could not understand it and tried to find to something on Google. But somewhere I found it’s a issue and it will be taken care of or handled by itself for the time being. But during analysis, I found one solution.

The problem is the URL length is getting higher than 1024. So for this, one has to reduce the number of files getting combined. So you can have more than one group of files and put it in different composite scripts tag.

I have added one script manager proxy and added a compositscript tag it in it and pasted almost half of the scripts in it. And it resolved the issue as:

 <asp:ScriptManager ID="ScriptManager1" runat="server">
            <CompositeScript>
                <Scripts>
                    <asp:ScriptReference name="MicrosoftAjax.js"/>
	                <asp:ScriptReference name="MicrosoftAjaxWebForms.js"/>
	                <asp:ScriptReference name="AjaxControlToolkit.Common.Common.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Common.DateTime.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Compat.Timer.Timer.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
                </Scripts>
            </CompositeScript>
        </asp:ScriptManager>
        <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
            <CompositeScript>
                <Scripts>
                <asp:ScriptReference name="AjaxControlToolkit.Animation.Animations.js" 
		assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Animation.AnimationBehavior.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.PopupExtender.PopupBehavior.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Common.Threading.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
	                <asp:ScriptReference 
			name="AjaxControlToolkit.Calendar.CalendarBehavior.js" 
			assembly="AjaxControlToolkit, Version=3.0.30930.28736, 
			Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
                </Scripts>
            </CompositeScript>
        </asp:ScriptManagerProxy>

Now it will combine the resource files in two files. You can add more CompositScript tags if required.

Hope all of you have enjoyed this and benefited from it.

Cheers,

Brij


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Brij
Software Developer (Senior)
India India
Brij is a 3-times Microsoft MVP in ASP.NET/IIS Category and a passionate .NET developer. More than 6 years of experience in IT field, currently serving a MNC as a Tech Lead/Architect.
 
He is a very passionate .NET developer and have expertise over Web technologies like ASP.NET 2.0/3.5/4.0, jQuery, JSON, Javascript, IIS and related technologies. He is also a Exchange Server (EWS) Specialist. He has great experience in design patterns and N-Tier Architecture.
 
He is also certified as Microsoft Certified Technologies Specialist-ASP.NET and Microsoft Certified Technologies Specialist-WCF in .NET 4.0. He has also received several awards at various forums and his various articles got listed as "Article of the day" at ASP.NET Microsoft Official Website www.asp.net.
 
He has done MCA from NIT Durgapur and completed his graduation from Lucknow University.
 
Learning new technologies and sharing knowledge excites him most. Blogging, solving problems at various forums, helping people, keeps him busy entire day.


Visit his Blog: Brij's arena of .NET
 
Area of Expertise :
C#, ASP.NET 2.0,3.5,4.0, AJAX, JQuery, JSON, XML, XSLT, ADO.Net, WCF, Active Directory, Exchange Server 2007 (EWS), Java script, Web Services ,Win services, DotnetNuke, WSS 3.0,Sharepoint Designer, SQL Server 2000/2005/2008
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 5 Pinmemberzhxhdean9-Dec-12 19:38 
GeneralMy vote of 5 PinmemberAkram El Assas12-May-12 5:57 
GeneralGreat! Pinmembersimijohn12-Jun-11 22:43 
GeneralRe: Great! PinmvpBrij12-Jun-11 23:01 
GeneralMy vote of 5 PinmvpKunal_Chowdhury3-May-11 1:38 
GeneralRe: My vote of 5 PinmvpBrij3-May-11 5:27 
GeneralMy vote of 5 Pinmemberkoolprasad20031-May-11 19:14 
GeneralRe: My vote of 5 PinmvpBrij1-May-11 21:21 
Thanks Man!!
Cheers!!
Brij
Visit my Blog: http://brijbhushan.net


General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 1 May 2011
Article Copyright 2011 by Brij
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid