How Can I Improve performance of ASP.NET Application

by iatanasov 29. July 2007 06:44

 

Step1: Learn "Hot to work with strings?"

If you are c++ programmer and start with modern languages while Delphi, c# or Java, there have thausands of lines writen for working with strings.

Never not use:

    string result = ""; //instead result = string.Empty.

For this method of initialization of string variable Microsoft are make couple of optimization.

If you want to format same string, don't write:

    result = var1 + " this is " + var2 + " the best " var3 + " ."; //where var 1-3 are string variable

Just use:

    result = String.Format("{0} this is {1} the best {2} ."

If you must concatenated  more that four string, in language exist StringBuilder. I'm make test with 1000 concatanations of strin. For "result += result" this take about twenty 

seconds, instead for StringBuilder is three seconds. 

If you campare strings, don't use equals operator (this is stupid  least). Use String.Compar() or string result = "test", result.Equals("tests")

Step2: Use "Using" block for working with database and file system.

if you open file or database connection just write:

        using(SqlConnection connection = new SqlConnection(connectionString))
        {
             connection.Open()
        } //after programs pass this line, connection is closed

What deliver this functionallity for you?

  1. if you forgot to close connection, it's closed.
  2. couple of lines code, that you have to write. 

Step4: Use generics  List instead ArrayList. 

ArrayList object make boxing and unboxing in every operation with it, for this reason Microsoft ® release List<T> (generic lists) with .net 2.0. When they are make optimization , we just have to use it.

Never don't write:

    ArrayList customers = new ArrayList();  // List<Customer> customer = new List<Customer>();

    customers.add(new Customer());         // it's same

    Customer temp = customers[i] as Customer; //  Customer temp = customers[i];//without unboxing;

Step5: Don't use ssl on every pages

I'm look person that write e-commerce application and they put ssl on every web pages. This isn't right decision, you must implement you chec-out process with ASP.NET wizard

and put user iteration only on couple of pages. When user browse web site , there no reason to have SSL on every page. If you open sites while amazon i yahoo shopping you will

see,  that use ssl when you buy product and must enter same sensitive information.

For you stay problem to define which pages exatly have need to be put on SSL line, this one will be perfect fix the problem with your ASP.NET perfomance.

Conclusion:

  • Working with string is imporatnt for web development.
  • Minimazing using of ArrayList, instead use Custom Obgects with Generic List.
  • Minimazing using of SSL, this will put down your web server. 

 

Currently rated 4.0 by 3 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

asp.net 2.0 | web development

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag




Live preview

October 12. 2008 01:17

Gravatar

Powered by BlogEngine.NET 1.1.0.7
Theme by Mads Kristensen

About the author

Ivan Atanasov - web developer
E-mail me Send mail Subscribe Feed

Calendar

<<  October 2008  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Pages

    Recent posts

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008 it-coder.com

    Sign in