I recommend reading the Microsoft Patterns and Practices book called "Improving .NET application Performance and Scalability". Here's the online version of the book.

There is a great deal of methodologies that needs to be followed before jumping into code improvement and that's why I recommend reading the book. But here are a few random programming advices related to Microsoft technologies that I would like to share as a preview; those were taken off or derived from the book:

  • (.NET) To instrument your code, you might want to take a look at the Microsoft Enterprise Library
  • (.NET) There are two types of garbage collectors you can use: the Server GC or the Workstation GC. There are cases where you might choose one over the other
  • (.NET) Use StringBuilder for your temporary string buffers
  • (SQL) Regardless of their type: make sure you keep your transactions as short as possible. You should also consider your isolation level and keep read operations to a minimum inside a transaction
  • (SQL) Separate read-only requests and transactional requests
  • (SQL) Use the SQL Profiler to figure out what are the queries that need to be optimized then SQL Analyzer to find out about missing indexes. Use the Index Tuning Wizard to fine tune your indexes
  • (ASP.NET) Disable Viewstate if you don't need it
  • (ASP.NET) Partition your page into sections, and create custom controls for those sections to then enable output caching
  • (ASP.NET) Use HttpResponse.IsClientConnected before running an expensive operation on the server-side since the client might not be connected anymore
  • (ASP.NET) When using Response.Redirect, make sure an exception isn't thrown by passing "false" to the proper overloaded method otherwise it throws a ThreadAbortException and this might hurt you later on
  • (ASP.NET) Implement a global error handler and make sure the error is persisted so you are aware of what is going on
  • (ASP.NET) Short-circuit the HTTP pipeline by removing unused handlers (in the HttpModules section of your web.config)
  • (ASP.NET) Web services use MTA exclusively; there is a significant overhead in making cross-apartment calls

Of course there is more much of it. The "Code Review" section is also a good source of facts you want to be aware of.

The book is a little old but hopefully this information will still incite you to take a look at it.