Increase Performance in an asp.net Application
For every enterprise level application the key to make that application successful is the responsiveness of the application. ASP.NET offers a great deal of the features for developing web based enterprise applications, but sometimes, due to adhering to best practices, the application is not as fast as it should be. Here are the some useful suggestions to make your application super fast.
- Always set debug=”false” in web.config production environment.
- Always set trace=”false” in web.config production environment
- If you are using asp.net 2.0 or higher version then always use precompiled version of your code and also prefer web application project over website. If you are using website then always publish it and then upload that precompiled version of your site in production environment.
- Always compile your project in Release Mode before uploading application to production environment.
- Decrease your html kb as much as you can for that use tables less html using div’s and if possible then do not give big name to your control it will increase your html kb as asp.net uses client Id to differentiate all the controls. If you are creating custom controls then you can overwrite your clientid and uniqueId.
- Use cache api as much as possible it will decrease your server roundtrip and boost application performance. ASP.NET 2.0 or higher version provides functionality called sqlcachedependancy for your database caching. It will validate cache with your database operation like insert,update and delete and if not possible with it then use the file base caching.
- Remove blank spaces from your html it will increase your kb. You can use regular expression to remove white spaces. I will post the code for removing white spaces next posts.
- For asp.net 2.0 and higher version use master pages. It will increase your performance.
- Prefer database reader over dataset unless and until you have specific reason to use database.
- Use ADO.NET asynchronous calls for ado.net methods. asp.net 2.0 or higher version is supporting your performance. If you are using same procedure or command multiple time then use ADO.NET Prepare command it will increase your performance.
- Do IIS performance tuning as per your requirement.
- Disable view state for your controls if possible. If you are using asp.net 2.0 or higher version then use asp.net control state instead of view state. Store view state in session or database by overriding the default methods for storing view state.
- User Server.Transfer instead of response.redirect.
- Always use inproc session state if possible.
- Use Ajax for your application wisely. Lots of Ajax calls for a page will also decrease your performance.
- Measure your application performance with tools like redgate profiler,firebug and whyslovw from yahoo.
- User System.Text.StringBuilder for string concatenation its 4 times more faster then the normal strings.
- Use Separate CSS files for styling of application.
- User database paging over normal paging while displaying huge amount of data.
- Call web service from java script instead of server side. Use asynchronous calls to call a web method from web service.
That’s it!!…..Happy Programming...