Wednesday, August 12, 2009

Best Practises during ASP.Net development.

• Minimize the amount and complexity of data stored in a session state. The larger and more complex the data is, the cost of serializing/deserializing of the data is higher.
• Avoid unnecessary round-trips to the server - Code like validating user input can be handled at the client side itself.
• Use Page.IsPostback to avoid unnecessary processing on a round trip.
• Use Server.Transfer for redirecting between pages in the same application. This will avoid unnecessary client-side redirection.
• Don't rely on exceptions in the code. Exceptions reduce performance. Do not catch the exception itself before handling the condition
• Save server control view state only when necessary.
• Use server controls in appropriate circumstances. Even though are they are very easy to implement, they are expensive because they are server resources
• The in-proc model of session management is the fastest of the three options. SQL Server option has the highest performance hit.
• Disable session when not using it.
• Choose the best suited session-state provider - In-process is the fastest option.
• Use SQL server stored procedures for data access.
• Use the SQLDataReader class for a fast forward-only data cursor.
• Cache data and page output whenever possible.
• Disable debug mode before deploying the application.
• For multiple Response.Write instead of creating strings using concatenation.
• String Concatenation can really decrease the performance of your application if it is not handled properly.
• Resources should be cleaned up when an exception occurs.So close the resources in the finally block. Using a try/finally block ensures that resources are disposed even if an exception occurs.
• Use index properly in sql server.

No comments: