June 08, 2007 12:06 AM

It’s All in the Timing

Reduce the Initial Load Time of Your ASP.NET Web Pages
DevConnections
Rating: (0)

asp:Feature

LANGUAGES:C#

ASP.NETVERSIONS: 2.0

 

It?s All in the Timing

Reduce the Initial Load Time of Your ASP.NET Web Pages

 

 

This article highlights the strategies that one can adoptfor faster page renderings in ASP.NET. It discusses such factors as caching, viewstate,and ASP.NET page precompilation.

 

The Strategies

To start, reduce your working set size by removing allunnecessary .dll files. Reduce the size of your viewstate or disable italtogether to minimize the size of your viewstate and thus facilitate fasterpage rendering. You should disable viewstate for controls that do not requireit. Further, you can remove the runat=?server? form tag completely to reducepage size by 20 bytes. If you don?t remove this tag, the page itself passes onabout 20 bytes of information to viewstate, even when the page?s ViewStateproperty is set to false.

 

Use ASP.NET 2.0?s new feature called precompilationeffectively to reduce the page load time of your Web pages by compiling theapplication?s code at run time. You can pre-compile Web pages in yourapplication to reduce the working set size and boost application performance.

 

ASP.NET 2.0 provides this excellent feature and makes itavailable in the following two distinct modes:

  • In-place precompilation
  • Precompilation for deployment

 

You can learn more about precompilation, its types, andbenefits in my article ?BoostASP.NET Performance with Precompilation?.

 

You can set the autoEventWireup attribute to ?false? inthe Machine.config file to improve performance further. Refer to the codesnippet given here:

 

<configuration>

 <system.web>

   <pagesautoEventWireup="true|false" />

 </system.web>

</configuration>

 

The autoEventWireup attribute accepts a Boolean value thatindicates whether the ASP.NET page?s events are auto-wired. If the autoEventWireupis set to false, the runtime does not have to look for each of the page eventhandlers. MSDN states, ?When you explicitly set AutoEventWireup to true, VisualStudio .NET or Visual Studio 2005, by default, generates code to bind events totheir event-handler methods. At the same time, the ASP.NET page frameworkautomatically calls the event-handler methods based on their predefined names.This can lead to the same event-handler method being called two times when thepage runs.?

 

Further, ensure that the tables, cells, and images you usein your Web pages have their width and height set properly so that the browsercan prepare placeholders for items and render faster. Avoidance of excessivelylarge images, nested tables, and redundant tags in the Web pages would alsoyield a faster page render.

 

You can use caching for better performance of successivepage renderings. It is great for storing relatively static application data asit reads data from memory to avoid repeatedly retrieving data from a database,file, or any other repository. Judicious use of the right type of caching cango a long way toward improving the performance of your ASP.NET applications,and it can reduce the time required for successive page renderings where your Webpage requires relatively static data.

 

You can check the load time of your ASP.NET Web pages byenabling the trace in the page. For this, enable the trace option in your .aspxfile and set the TraceMode property = ?SortByTime?. Refer to the code snippetbelow:

 

<%@ Page Language="C#"AutoEventWireup="true" trace="true"TraceMode="SortByTime" CodeFile="Test.aspx.cs"Inherits="Test" %>

 

Follow these additional strategies for improving theoverall performance of your ASP.NET Web applications:

  • Avoidance of unnecessary roundtrips to the Webserver through the use of client-side scripts
  • Efficient exception handling and data accessstrategies
  • Optimized code for efficient garbage collection

 

Read my article ?Improving Application Performance in .Net? to learn moreabout the strategies that can be followed to improve the overall performance ofyour ASP.NET Web applications.

 

Conclusion

In essence, one should be aware of the most importantstrategies on how to optimize the applications so that they have the leastamount of memory, processor, network, and IO overload. Here we took a quick lookat some of the best measures for improving the response time of your ASP.NET Webpages.

 

Working extensively in Microsoft technologies for more than 10years, Joydip Kanjilal is a SeniorTechnical Leader in the Design and Architecture team for a company in Hyderabad, India. His programmingskills include C, C++, Java, C#, VB, VC++, ASP.NET, XML, and UML. An ASP.NETMVP, he has worked with .NET and C# for more than five years. Reach Joydip at mailto:joydipkanjilal@yahoo.com orat his blog at: http://aspadvice.com/blogs/joydip/.

 

 

 

 

Add a Comment

There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement




Comments from the DevConnections Community

Join our community of development pros.

Windows problem

I all, I have a problem on my Windows Vista that began afetr the purchase of an external Hard Disk Freecom. A few days afetr the purchase I discon...

Most Recent Posts

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS