- Viewstate
View state is the wonder mechanism that shows the details of the entry posted on the server. It is loaded every time ifrom the server. This option looks like an 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 there is no need for it then it can be disabled.
EnableViewState = "false" needs to be given based on the requirements. It can be given at the control, page and config level settings.
- Avoid Session and Application Variables
A Session is a storage mechanism that helps developers to take values 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 IIS. When this Session variable is used in a page that is accessed by many numbers then it will occupy more memory allocation and gives additional overhead to the IIS. It will make the performance slow.
It can be avoided for most scenarios . If you want to send the information across pages then we can use a Cross Post-back, Query string with encryption. If you want to store the information within the page then caching the object is the best way.
- Use Caching
ASP.Net has the very significant feature of a 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 with the Output cache. What it does is, it stores the content on IIS. When the page is requested it will be loaded immediately from the IIS for the certain period of time. Similarly Fragment paging can be used to store the part of the web page.
- Effectively use CSS and Script files
If you have large CSS files that are used for the entire site in multiple pages, then based on the requirements, it can be split and stored with different names. It will minimize the loading time of the pages.
- Images sizes
Overuse 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 done on the CSS colors or use light-weight images to be repeated in all of the pages.
- CSS based layout
The entire web page design is controlled by the CSS using the div tags instead of table layout. It increases the page loading performance dramatically. It will help to enforce the 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.
- Avoid Round trips
We can avoid unnecessary database hits to load the unchanged content in the database. We should use the IsPostBack method to avoid round trips to the database.
- Validate using JavaScript
Manual validation can be done at the client browser instead of doing at the server side. JavaScript helps 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 do the server side validation before going into the process.
- Clear the Garbage Collection
Normally .Net applications use Garbage Collection to clean the unused resources from memory. But it takes time to clear the unused objects from memory.
There are many ways to clean the unused resources. But not all of the methods are recommended. But we can use the dispose method in the finally block to clean up the resources. Moreover we need to close the connection. It will immediately free the resources and provides space in memory.
- 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 be encrypted and stored on the client side. It can be tampered with by hackers as well.
- Implement Dynamic Paging
When we load a large number of records into the 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.
- Use Stored Procedure
Try to use Stored Procedures. They will increase the performance of the web pages. Because it is stored as a complied object in the database and it uses the query execution plans. If you pass the query then it will make a network query. In the Stored Procedure a single line will be passed to the backend.
- 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.
- Use Dataset
A DataSet is not lightweight compared with DataReader. But it has the advantages of a disconnected architecture. A DataSet will consume a substantial amount of memory. Even though it can have more than one day. If you want to perform many operations while loading the page itself, then it might be better to go with a DataSet. Once data is loaded into the DataSet it can be used later also.
- Use String Builder in place of String
When we append the strings like mail formatting in the server side then we can use StringBuilder. If you use string for concatenation, what it does every time is it creates the new storage location for storing that string. It occupies more spaces in memory. But if we use the StringBuilder class in C# then it consumes more memory space than String.
- Use Server.Transfer
If you want to transfer the page within 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.
- Use Threads
Threads are an important mechanism in programming to utilize the system resources effectively. When we want to do a background process then it can be called a background process.
Consider the example of when clicked on send, it should send the mail to 5 lakhs members yet there is no need to wait for all the processes to complete. Just call the mail sending process as a background thread then proceed to do the further processing, because the sending of the mail is not dependent on any of the other processes.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Yan AungPosted Jun 14, 2019, 10:00 PM
Thank you Sir
Jay KPosted May 12, 2017, 10:47 AM
Thank you very much for posting.
Matt WatsonPosted Dec 28, 2016, 5:02 PM
Check out Prefix which is free. It can show you every web request, what database queries are running, etc.http://stackify.com/prefix
Navnath UgalePosted Jan 3, 2016, 12:20 PM
very nice
Humayun Kabir MamunPosted Oct 29, 2015, 3:46 AM
Nice...
Yasir MahmoodPosted Mar 24, 2015, 12:56 AM
Excellent Post
Manish Kumar ChoudharyPosted Dec 27, 2014, 11:42 PM
Nice and helpful tips. ..
Sameer ShahPosted Dec 27, 2014, 2:43 PM
Very helpful article.However I would like to add some information regarding caching. ASP.Net caching is an inproc caching solution not suitable for environments with multiple application servers using the same set of data. A out of process distributed caching solution is vital in such situations which enables to share same set of data with multiple applications and processes. E.g. NCache (http://www.alachisoft.com/ncache/) is one of the distributed caching solutions for .Net applications which provides linear scalability along with multiple topologies and rich set of caching features to satisfy application’s need.
Asif KhanPosted Dec 16, 2014, 6:26 AM
thumbs up.!!
bala krishnaPosted Dec 7, 2010, 7:50 AM
exlent article , it will be very helpful to me, u have done a great job
Karthika PalaniswamyPosted Oct 13, 2009, 6:17 AM
Your tips to improve the performance of web applications, defiantly will give best result. Here I want to share some more points, which is:-<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p> Should try to avoid try-catch blocks which perform poorly, Exceptions should be used only in unavoidable exceptional situations.<o:p></o:p> Should try to keep JavaScript and CSS in external files and use ‘link’ tags rather than ‘@import’.<o:p></o:p> Unless it’s necessary should avoid to using ‘Redirect’, Consider ‘Server.Transfer’, it performs better in some conditions. <o:p></o:p> Should minimize utility of ‘I frames’ in the web pages.<o:p></o:p> 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.<o:p></o:p> Should try to avoid DOM objects on the web pages, which is heavy weight, it will reduce the performance of web applications.<o:p></o:p> Thanks too…<o:p></o:p> <o:p> </o:p>