Skip to main content

10 Tips For Enhancing Performance Of A Web Application

ASP.NET is a programming framework developed by Microsoft that enables the programmers to develop web applications, web services and dynamic websites. ASP.NET enables the developers to write code using any language supported by Microsoft's .NET framework.

Prove you're a Dev Guru! Take the test now! (opens in new tab)

ASP.NET has made life so easy for so many web developers that sometimes it's easy for them not to take time to structure their applications for best performance.

This article highlights 10 basic performance-enhancing tips for web applications that a developer can implement very easily.

1. Turn off Tracing if it is not required. Tracing is only useful to developers, who can use it to track the execution of the web application during testing. It degrades the performance of the application and can expose some private information. See the code below to turn off the trace

2. Turning off Session State can enhance the performance of the application. Session state is one of the powerful features of the ASP.NET, used to store user-specific data.

By default, ASP.NET manages Session state, so even if you're not using it, Session State is still taking up memory and hindering the performance of the application. Consider the following code to disable the Session state in your application.

3. Disable the View State of the controls or pages if you're not using it. View State is a feature of ASP.NET that enables developers to store data in hidden input fields within the generated page. ASP.NET uses View State to allow data or settings to persist. When a page posts back to the server, the server then parses, validates and applies the View State data to the respective controls of the page.

View State increases the total amount of data transferred when a page is served. That data also needs to be serialised and deserialised, which adds an overhead for the application and degrades performance.

Consider using following code to disable View state of the page

4. In the web.config file set debug=false. This value is set to true by default, when you create a new application. This is very useful during the development phase, as it helps in debugging the code. While deploying the application, set its value to false.

5. When you need to move to another page on the same server, use Server.Transfer instead of Response.Redirect. Response.Redirect tells the browser to move to the new page and hence an extra request to your web server. However, Server.Transfer transfers the controls to the new page within your server.

6. If you want to validate the values of some controls, use client scripts instead of validating the inputs at server side. This will make the web application more user-friendly as pages will not post back to the server for validating the inputs.

7. You should make sure the code you have written does not execute multiple times if it's not required to. To prevent executing the code for page initialisation logic multiple times, you should use the Page.IsPostback property. This property should be used to ensure that the page initialisation code executes once, and not for every response to client.

8. Avoid passing references to the objects as parameters to the functions. When you pass reference to an object, it's slower than accessing the value from the stack.

9. Only show subsets of the data at a time by using the Paging feature of the controls. It enables the pages to load much more quickly.

10. Use Caching of entire pages, fragment of the pages and user controls to enhance the performance of the web application. You should always use Caching on pages whose content changes less frequently. ASP.NET engine stores those static pages in memory, and does not have to create a new page for every repeated request for those pages, which in turn enhances the performance. monitors all leading technology stories and rounds them up to help you save time hunting them down.