SIGN UP MEMBER LOGIN:    
ARTICLE

Tips to improve the performance in ASP.Net application

Posted by Senthilkumar Articles | Coding Best Practices July 29, 2009
In this article we will see some tips to improve the asp.net web application performance.
Reader Level:

 
Here are few tips to improve the performance of your web application.

  1. Viewstate

    View state is wonder mechanism which shows the details of entry which posted on the server. Every time its get loaded from the server. This option looks like extra feature for the end users. This needs to be loaded from the server and it adds more size to the page But it will affect the performance when we have many controls in the page like user registration. So, if it is no need then it can be disabled.

    EnableViewState = "false" needs to be given based on the requirement. It can be given at the control, page and config level settings.
     
  2. Avoid Session and Application Variables

    Session is storage mechanism which helps the developers to take the value across the pages. It will be stored based on the session state chosen. By default it will be stored in the Inproc. That default settings uses the IIS. When use this Session variable in a page, which is accessed by many numbers then it will occupy more memory allocation and gives addition overhead to the IIS. It will make the slow performance.

    Most of the scenarios it can be avoided. If you want to send the information across the pages then we can use Cross Post back, Query string with encrypted. If you want to store the information with in the page, then cache object is best way.
     
  3. Use Caching

    ASP.Net has the very significant feature of caching mechanism. It gives more performance and avoids the client/server process. There are three types of caching in ASP.Net.

    If there is any static content in the full pages then it should be used the Output cache. What it does, it stores the content on IIS. When the page is request it will load immediately from the IIS for the certain period of time. Similarly Fragment paging can be used for store the part of web page.
     
  4. Effectively use CSS and Script files

    If you have big CSS files which used for the entire site different pages, then based on the requirement it can be spitted and stored with different names. It will minimize the loading time of the pages.
     
  5. Images sizes

    Over use of images in the web site affect the web page performance. It takes time to load the images especially on dial up connections. Instead of using the background images, it can be achieved on the CSS colors or use light weight images to repeat in the entire pages.
     
  6. CSS based layout

    The entire web page design controlled by the CSS using the div tags instead of table layout. It increases the page loading performance dramatically. It will help to enforce same standard guideline throughout the website. It will reduce the future changes easily. When we use the nested table layout it takes more time for rendering.
     
  7. Avoid Round trips

    We can avoid unnecessary database hits to load the unchanged content in the database. We should use IsPostBack method to avoid round trips to database.
     
  8. Validate using JavaScript

    Manual validation can be done at the client browser instead of doing at the server side. The JavaScript help us to do the validation at the client side. This will reduce the additional overhead to the server.

    The plug-in software helps to disable the coding in the client browser. So, the sensitive application should to the server side validation before go into the process.
     
  9. Clear the Garbage Collection

    Normally .Net application use the Garbage collection to clean the unused the resources from the memory. But it takes own time to clear the unused objects from the memory.

    There are lots of ways to clean the unused the resource. But not all the methods recommended. But we can use dispose method in the finally block to clean the resources. More over we have to close the connection. It will immediately free the resources and gives spaces in the memory.
     
  10. Avoid bulk data store on client side

    Try to avoid more data on the client side. It will affect the web page loading. When we store more data on the hidden control then it will encrypt and store on the client side. It can be tamper by hackers as well.
     
  11. Implement Dynamic Paging

    When we load bulk number of records in server data controls like GridView, DataList, and ListView it will take time to load. So we can show only the current page data through the dynamic paging.
     
  12. Use Stored Procedure

    Try to use stored procedure maximum. It will increase the performance of the web pages. Because it is stored as complied object in the database and it uses the query execution plans. If you pass the query then it will make network query. In the stored procedure single line will be passed to the backend.
     
  13. Use XML and XSLT

    XML and XSLT will speed up the page performance. If the process is not more complex then it can be implemented in XSLT.
     
  14. Use Dataset

    The DataSet is not light weight when compare with DataReader. But it has the advantages of disconnected oriented architecture. The DataSet will consume lot of memory. Even though it can have more than one day. If you want to perform many operations while loading the page itself, then you can better go with DataSet. Once data is loaded into DataSet then it can be used later also.
     
  15. Use String Builder in place of String

    When we append the strings like mail formatting in server side, then we can use String Builder. If you use string for concatenation, what it does every time it create the new storage location for place that string. It occupies more spaces in memory. But if we use String Builder class in C# it consumes more memory space than String.
     
  16. Use Server.Transfer

    If you want to transfer the page with in the current server then we can use the Server.Transfer method. It avoids roundtrips between the browser and server. But it won't update the browser history.
     
  17. Use Threads

    Thread is important mechanism in the programming language to utilize the system resources effectively. When we want to do background process then it can be called as background process.

    Consider an example, when click on send, it should sends the mail to 5 lakhs members that time no need to wait for all the process completion. Just call the mail sending process as background thread then go ahead for the further process. Because this mail sending not depend on the any other process.

Login to add your contents and source code to this article
share this article :
post comment
 

exlent article ,

it will be very helpful to me,
u have done a great job

Posted by bala krishna Dec 07, 2010

Your tips to improve the performance of web applications, defiantly will give best result. Here I want to share some more points, which is:-

Should try to avoid try-catch blocks which perform poorly, Exceptions should be used only in unavoidable exceptional situations.

Should try to keep JavaScript and CSS in external files and use ‘link’ tags rather than ‘@import’.

Unless it’s necessary should avoid to using ‘Redirect’, Consider ‘Server.Transfer’, it performs better in some conditions.

Should minimize utility of ‘I frames’ in the web pages.

Then images….., correct formatted Images should be used on the basis of its needs, for example: As background image, big image or a screenshot, the effective format is JPG/JPEG. For graphics like button images, header images, footer images, navigation bar images the best format is PNG.

Should try to avoid DOM objects on the web pages, which is heavy weight, it will reduce the performance of web applications.

Thanks too…

 

Posted by Karthika Palaniswamy Oct 13, 2009
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor