Posts Tagged ‘Best Practices to improve performance’

10 Simple Steps to improve performance of ASP.Net Application after complete development?

June 16, 2011 Leave a comment

How to improve the ASP.Net application once it is completed development? 

Most of the developers dont have any awareness about the performance at the time of coding and once in the deployment stage it will effect the performance of the website then it is very hard to make good performance. Here we are describing 10 very useful and time consuming performance tips that can be easily applied even after the complete development. We can follow this performance tips once completed our website development. 

10 simple tips to improve website after the development in ASP.Net,C#
1) Turn off Tracing If it is not required

When need to trace should be enable : It can be useful only by developers for monitoring trace logging. Once the application is on live there is no need to trace and can be make it as disable so that improve the performance.We can disable tracing in web.config by using following codes.

<trace enabled=”false” requestLimit=”10” pageoutput=”false” traceMode=”SortByTime” localOnly=”true”>

2) If we are not using Session variable, turn off Session.  

Session variable is used to track the current user details like authenticate user, shopping cart etc. Session is a good feature in ASP.Net but it will be take more time to use it, so it is better to don’t use session as possible and disable session state.

<@%Page EnableSessionState=”false”%>
If use the session state only to retrieve data from it and not to update it, make the session state read only by using the directive,
<@%Page EnableSessionState =”ReadOnly”%>

3) Disable View State
It’s an automatic facility provided by ASP.Net to store data in between the page postback. In some scenario we don’t need to use view state like static data displaying, Displaying list of data from database without any operation etc.. In this case we can disable view state. We can disable view state by pagewise or control wise.

<%@ Page EnableViewState=”false” %>

4) Set debug=false in web.config
On the development phase, there will be debug = true state in web.config file. Once we deployed, we don’t need this mode, because there will be a pdb files while deployment. So we can set debug=”false” in the web.config before deployment.

5) Avoid Response.Redirect
Response.Redirect tell to the application that just go to the given link and it will be a time expensive. If we wanto load a page in the server itself, we can use Server.Transfer method.

6) Use the String builder to concatenate string
If we use string to concatenate strings many times, it will create each time new object for the string and assign new concatenated string to new object. It will time expensive, so we can use stringbuilder instead of string to concatenate string variables.

7) Avoid throwing exceptions

Exceptions are very heaviest resources and its better to use in very urgency case. The better method is using try catch for every methods track errors for futher verification by developer instead of throwing to users.

8) Use Page.ISPostBack
Make sure you don’t execute code needlessly. Use Page.ISPostBack property to ensure that you only perform page initialization logic when a page is first time loaded and not in response to client postbacks.

9) Use Foreach loop instead of For loop for String Iteration
For string iteration purpose Foreach loop has more performance than for loop. So its better to use for each loop instead of for loop.

10) Make JavaScript and CSS External

If our javascript and css are in external file, it will be more faster because most of the case browser cached the files and downloaded very fast.So its better to use javscript and css as external file.

%d bloggers like this: