RSS

Improve perfomance in asp.net web

While developing any web site one should keep some point into their mind.

1. Set debug=false under compilation as follows:-

2. Turn off Tracing unless until required.

3. Turn off Session State, if not required.

4. 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

5. Disable ViewState as and when not required.

6. EnableViewState=”false”

7. Avoid frequent round trips to the Database.

8. Use Caching to improve the performance of your application.

9. Validate all Input received from the Users.

10. Use Finally Method to kill resources.

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

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

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

14. 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.

15. Enabling buffering will improve the performance, like Response. Buffer=True.

16. 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.
Use arraylist and take all data into this then fetch data from arraylist by Particular Page Number and bind only those data.

17. Use JavaScript file instead of writing in same file.
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.
Reduce cookie size

19. Compress CSS, JavaScript and Images
Online compressors are available; to compress file please refers following web and put your file content into there and get optimize code.
http://iceyboard.no-ip.org/projects/css_compressor for CSS compression
http://www.xtreeme.com/javascript-optimizer/ . For JS Compression

20 .Use Cache appropriately
i. Page output caching:

ii. Page fragment caching:
Write a previous code into each User Control
iii. Data caching:

Protected void Page_Load(Object src, EventArgs e) {
DataView dv = (DataView)Cache.Get(“EmployeesDataView”);
if (dv == null) { // wasn’t thereSqlConnection conn =
new SqlConnection(“server=localhost;uid=sa;pwd=;database=Test”);
SqlDataAdapter da =new SqlDataAdapter(“select * from Employees”, conn);
DataSet ds = new DataSet();da.Fill(ds, “Employees”);
dv = ds.Tables[“Employees”].DefaultView;
Cache.Insert(“EmployeesDataView”, dv);onn.Close();}
else
Response.Write(“aa”);
lb1.DataSource = dv;
lb1.DataTextField = “Name”;
lb1.DataValueField = “Age”;
DataBind();}

Use server side compression software such as Port80???s http://www.port80software.com/products/httpzip/

Advertisements
 
3 Comments

Posted by on March 9, 2011 in Uncategorized