Click here to Skip to main content
6,822,613 members and growing! (19,903 online)
Email Password   helpLost your password?
Web Development » ASP.NET » General     Beginner License: The Code Project Open License (CPOL)

ASP.NET Web Site Performance Improvement

By Ashrafur Rahaman

Tips to speed up your ASP.NET applications.
XML, .NET, ASP.NET, Dev, SysAdmin
Revision:6 (See All)
Posted:26 May 2009
Updated:28 May 2009
Views:19,262
Bookmarked:66 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
16 votes for this article.
Popularity: 5.62 Rating: 4.67 out of 5

1

2
2 votes, 12.5%
3
1 vote, 6.3%
4
13 votes, 81.3%
5

Introduction

Recently, I developed a web application which calls many services and loads a lot of data in every page with a lot of calculation in the background from the database, so the site became slower. Then, I started searching Google to find out a good solution, and got some real good ideas to improve my web application's performance. Here, in this article, I am sharing the tips I applied in the application to improve its performance, and it really works fine now.

Things I Have Done

1. HTTP Compression

HTTP compression is used to compress page content from the server end. It compress HTTP requests and responses, so is a great performance improvement. My project is hosted in Windows Server 2003, and I implemented HTTP compression after reading this article.

2. Disable Possible ViewState

View State allows the page state to be persisted with the client, and it does not require cookies or server memory. View State saves data in a hidden input filed inside a page. Definitely, it is a powerful feature, but the drawback is it increases page size and memory allocation in the server.

So, we should avoid View State where it is not necessary. Especially, in the case of DataGrid controls, we should avoid View State as it loads all the grid data in the page state.

In my application, I disabled View State for most of the controls and pages where View State is not necessary. THis made the page sizes smaller.

3. Changes in the Web.Config File

  1. Use page caching:
  2. This will save your page only for a certain amount of time, and the page will be faster to load. But, remember that if your page data changes frequently, it is not a good idea to use page caching.

    <caching>
    <outputCacheSettings>
        <outputCacheProfiles>
            <add name="cached" duration="600" 
                varyByParam="none" enabled="true"/>
        </outputCacheProfiles>
    </outputCacheSettings>
    </caching>
  3. Remove unnecessary httpModules from the web.config:
  4. <add name="ScriptModule" 
         type="System.Web.Handlers.ScriptModule, System.Web.Extensions, 
               Version=3.5.0.0, Culture=neutral, 
               PublicKeyToken=31BF3856AD364E35"/>
    <remove name="WindowsAuthentication" />
    <remove name="PassportAuthentication" />
    <remove name="AnonymousIdentification" />
    <remove name="UrlAuthorization" />
    <remove name="FileAuthorization" />
  5. Turn off trace:
  6. <trace enabled="false" pageOutput="false" />
  7. As I have used membership, I disabled automatic save for profiles:
  8. <profile enabled="true" automaticSaveEnabled="false" />
  9. Set debug=false:
  10. <compilation debug="false">

4. Implement Cache Dependency

Three types of cache dependencies are available:

  1. Caching Dependency on cached items
  2. Cache Dependency on a file
  3. Cache Dependency on SQL

For my project, I used cache dependency on file. For your project, you can choose to use a dependency based on which will be the best fit for your application. Here is a nice example of cache dependency on file.

5. Optimize Stylesheets

It is important to clean up style sheets and remove unnecessary code from style sheets because it increases the load time. Remove all unnecessary classes from style sheets and try to use a single CSS file. In my project, I have used a tool to reduce the size of my stylesheet. I used this service to reduce the size of my CSS file by 20%.

6. Optimize JavaScript

I optimize my JavaScript using this service.

7. JS and CSS File Position

According to the advice from some good articles, I put the CSS file declaration at the top of my master page. It is recommended to call CSS files at the top of a page because the page rendering will progressively become efficient.

I put JavaScript file links at the bottom of the main master file. If we put scripts at the top of the page, then it will cause unnecessarily high load times.

8. server.transfer() Instead of response.redirect()

Where possible, I use server.transfer() instead of response.redirect(). It loads pages faster because it posts only the form, not the complete page.

9. Client-side Script for Validation

For page validation, I use client-side validations instead of postbacks. This way, I reduce round trips in pages.

Points of Interest

There are many more things that can be done to improve the performance of a web application. Given below are the links of some very good articles:

History

  • 26th May, 2009: First version.

I plan to add more performance tuning tips in the future.

License

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

About the Author

Ashrafur Rahaman


Member
Lead programmers on project to finish the outsourced product, analyze requirement and define solution architecture for project. Design and maintain database. Software quality assurance, source control, bug tracking, feature and project schedule planning. Developed Statement of Work, setup project plan, designed Data Model and Web Application architecture in .NET 2.0/3.5 and SQL Server, and supervise a .net developer’s team.
Occupation: Team Leader
Company: Latitude-23
Location: Bangladesh Bangladesh

Other popular ASP.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 10 of 10 (Total in Forum: 10) (Refresh)FirstPrevNext
GeneralGreat and Excellent PinmemberVinceMc4:39 14 Aug '09  
GeneralHTTP Compression PinmemberSameer Alibhai5:04 7 Aug '09  
GeneralDisable ViewState Pinmembermark4asp6:55 23 Jun '09  
GeneralImage/static file caching PinmemberKen McAndrew3:14 2 Jun '09  
GeneralRealy Great PinmemberMohammad Jahedur Rahman19:37 1 Jun '09  
GeneralRe: Realy Great PinmemberAshrafur Rahaman9:33 2 Jun '09  
GeneralPoint# 8 PinmemberCybernate9:06 29 May '09  
QuestionRe: Point# 8 PinmemberKen McAndrew3:10 2 Jun '09  
GeneralMy vote of 5 Pinmemberyordan_georgiev2:03 29 May '09  
GeneralPoint #9 needs more clarification PinmemberT.D.Brown9:42 28 May '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

PermaLink | Privacy | Terms of Use
Last Updated: 28 May 2009
Editor: Smitha Vijayan
Copyright 2009 by Ashrafur Rahaman
Everything else Copyright © CodeProject, 1999-2010
Web19 | Advertise on the Code Project