For every ASP.NET developer, it is important to create and build applications that meet performance objectives. Moreover, one should understand the places wherein bottlenecks usually happen, the causes and the steps to consider in order preventing them from occurring in an application.
Below are twenty helpful tips in enhancing ASP.NET app performance.
- Disabling the Session State if it is not in use. It is turned on by default but could actually be turned off for certain pages, rather than for every leaf.
- Output buffering is a great feature that enables a programmer to batch all the work on the server then run a Response.Flush method out output data.
- Make sure to use the Release Build mode and not the Debug Build when deploying a site to production. By running in a debug mode, one is creating a PDB’s and cranking up the timeout.
- Avoid server-side validation but use client-side instead. This is because it would just consume important resources on the web providers and could cause more chat to and from.
- Take advantage of paging’s simplicity which only shows small subsets of data, allowing for faster page loading.
Use the Repeater Control. The platform is great but unfortunately has plenty of controls developed in HTML and do not create the greatest scalable HTML from the performance viewpoint.
- Tracing is awesome but it should be turned off. If not, it is important to edit the web.config and turn it off.
- Redirect’s are very chatty and they should be used only if transferring people to another physical web server. For any transfers within the data provider, use .transfer! to save a lot of needless HTTP requests.
- Always check the Page.IsValid when using Validator Controls. If bad data is received, then the IsValid page is set to false, thus it should be checked before processing forms.
- It is important not to execute code needlessly. Developers often forget to check the IsPostBack, which is a basic thing.
- Refrain from throwing exceptions and handling useless exceptions.
- Exceptions could cause slowdowns in web apps as well as in windows applications.
- Turn off the ViewState when not using it for post back. By default, the controls would turn on viewstate and would slow down a site.
- If one has opened any database files or connections, it’s important to close them at the end. The Finally block is the best place to do this since it’s the only code block that would surely execute.
- Use Quick Page Caching and the platform’s Cache API! There’s plenty of strategy involved in the process however such as when and what to cache.
- When updating binaries, it is necessary to use the AppOffline.htm and helpful in getting rid of generic error messages.
- Make sure to turn both Option Strict and Option Explicit on. If they have never been turned on, it should be turned on now and try and compile to fix all errors.
- If there is no SQL Server database, then use a remote State Service instead. It could be used for enterprise apps or high volume web applications.
- Avoid an in-process option and refrain from running the session state service on a local web server. These could cause server affinity.
- Keep page size to a minimum since large sizes could put increased load on the CPU because of increased processing which could lead to network congestion.
- Validate user input on the client to minimize round trips to the system. This further provides better user feedback.
Thus, above given tips surely proves an useful and effective guidelines for every developers. These above given points not only proves helpful for them in the .net development process but, also helps them to quicken the entire process to provide better result of their .net development project.