Er. alokpandey's Blog

While developing any web site, one should keep some points in mind

Posted in ASP.NET (C# & VB), C#, HTML and XHTML, J-Query, JavaScript, LINQ, PLINQ, SilverLight, VB by Alok Kumar Pandey on November 9, 2010

1) Set debug=false under compilation as follows:

<compilation default Language=”c#” debug=”false”>

2) Use Server.Transfer instead of Response.Redirect.

3) Always check Page.IsValid when using Validator Controls

4) Use Foreach loop instead of For loop for String Iteration.

5) Use Client-Side Validation. (but not all the time you have to validate even on the server side)

6) Check “Page.IsPostBack”. To avoid repetition code execution.

7) GIF and PNG are similar, but PNG typically produces a lower file size. (True, but some browsers not supporting PNG format)

8) Use the AppOffline.htm when updating binaries

9) Turn off Tracing unless until required. (by default it’s off, use on the pages where it’s required)

<trace enabled=”false” requestLimit=”10″ pageOutput=”false” traceMode=”SortByTime” localOnly=”true”/>

10) Precompiled pages and disable AutoEventWireup; setting the AutoEventWireup attribute to false in the Machine.config file.

11) Turn off Session State, if not required.

<sessionstate timeout=”20″ cookieless=”false” mode=”Off” stateconnectionstring=”tcpip=127.0.0.1:42424″ sqlconnectionstring=”data source=127.0.0.1;Trusted_Connection=no”>

12) Select the Release mode before making the final Build for your application.

This option is available in the Top Frame just under the Window Menu option. By default, the Mode is Debug

13) Disable ViewState when not required.

EnableViewState=”false”

14) Avoid frequent round trips to the Database.

15) Use Caching to improve the performance of your application.

16) Validate all Input received from the Users.

17) Use Finally Method to kill resources. (But not in the case of using)

18) The String and Stringbuilder Magic.

It is nice to use Stringbuilder instead of String when string are Amended. Strings occupy different memory location in every time of amended where stringbuilder use single memory location

19) Never use object value directly; first get object value in local variable and then use. It takes more time then variable reading.

20) Avoid Exceptions: Use If condition (if it is check proper condition)

21) Code optimization:  Avoid using code like x = x +1; it is always better to use x+=1.

22) Data Access Techniques: DataReaders provide a fast and efficient method of data retrieval. DataReader is much faster than DataSets as far as performance is concerned

23) Before doing a bulky ASP code processing, you can check to make sure Response.IsClientConnected.

24) As always, avoid session variables because each ASP page runs in a different thread and session calls will be serialized one by one. So, this will slow down the application. Instead of session variables you can use the QueryString collection or hidden variables in the form which holds the values.

25) Enabling buffering will improve the performance, like

<% response.buffer=true %>

Then use:

<% response.flush=true %>

26) Use Repeater control instead of DataGrid , DataList, Because It is efficient, customizable, and programmable.

27) Data listing is more time consume when large data are retrieve from database.

Paging will display only particular data but take load of all data.

Fetch only data that is needed for current page.

28) Avoid Inline JavaScript and CSS

29) Use single css file instead of multiple css file.

Try your best to combine all your CSS based classes into a single .css file as lot of .css files will cause a large amount of requests, regardless of the file sizes.

.css files are normally cached by browsers, so a single and heavy .css file doesn’t cause a long wait on each page request.

Inline .css classes could make HTML heavy, so again: go ahead with a single.css file.

30) Reduce cookie size

31) Compress CSS, JavaScript and Images

Online compressors are available; to compress file please refers following web and Replace your file content with optimize code.

http://iceyboard.no-ip.org/projects/css_compressor for CSS compression

www.xtreeme.com/javascript-optimizer/ . For JS Compression

32 .Use Cache appropriately

i. Page output caching:

<%@ OutputCache Duration=”3600″ VaryByParam=”none” %>

ii. Page fragment caching:

Write a Page output caching code into each User Control

iii. Data caching:

32) Don’t make the member variables public or proteted, try to keep private and use public/protected as properties.

33) Use strString=string.Empty instead of strString=”” . [And perhaps instead of strString=null also (?)]

34) Make your page files as light as possible. That is try to avoid unnecessary markups, e.g. use div elements instead of tables.

35) Write static messages in div and make it visible when necessary. This is faster than letting server set Text property of your label or div.

36) Retrieve data from database at once, if possible. Don’t add up to database trip as far as possible. For this, combine the datafields from different tables and select them.

47) Use short ID name for WebControl.

 

Advertisements

6 Responses

Subscribe to comments with RSS.

  1. mukesh said, on January 14, 2011 at 12:13 pm

    Nice, it is really helpful for developers

  2. Refugio said, on March 23, 2013 at 1:13 am

    This is exactly the 4th blog, of your site I actually checked
    out. Nonetheless I actually like this 1, Just Blinds “While developing any web site,
    one should keep some points in mind | Er. alokpandey’s Blog” the very best. Thanks ,Jessie

  3. It’s very trouble-free to find out any topic on net as compared to textbooks, as I found this article at this site.

  4. Juana said, on May 6, 2013 at 8:57 pm

    Its like you read my mind! You seem to know a lot
    about this, like you wrote the book in it or something.
    I think that you can do with a few pics to drive the message home a little bit,
    but instead of that, this is magnificent blog.
    A fantastic read. I will certainly be back.

  5. Buy Garcinia Cambogia said, on May 22, 2013 at 2:18 am

    Excellent pieces. Keep posting such kind of information
    on your blog. Im really impressed by your blog.
    Hi there, You’ve done an incredible job. I will definitely digg it and in my view recommend to my friends. I am confident they’ll be benefited from this website.

  6. tablettegraphique123.net said, on July 3, 2013 at 2:58 pm

    What’s up colleagues, fastidious post and fastidious arguments commented here, I am genuinely enjoying by these.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: