Top ASP.Net Performance Tips

ประกาศบน - Last Modified on

Active Server Pages (ASP) is Microsoft's original server-side script engine for developing dynamic Web pages. After more than a dozen years, ASP is still being used today with Microsoft platforms. Here are several performance tips for developers that want to get the most out of ASP applications. 

 

Output buffering

This is an excellent feature developers should always take advantage of when possible. This will batch of all of the work on the server, and then with the run of a Response.Flush method, all of the output is executed. Output buffering will avoid the constant back and forth communication with the server that can slow down performance.

 

To do this, first code

 

<%response.buffer=true%>

 

and then

 

<%response.flush=

true%>

 

 

Instead of using Response.Redirect, use HTTPServerUtility.Transfer

Redirects are also resource-heavy and should only be used when transferring users to another Web server.  With HTTPServerUtility.Transfer, you can save many HTTP requests that aren't needed for transfers that are within your server.

 

Make sure to turn off tracing

Tracing is a very powerful tool when used correctly. But once an application is ready to be deployed you must be certain that it has been turned off. If by chance you have forgotten, you will need to edit your web.config to turn it off and conserve all of the overhead that it uses.

 

Here is how it is done:

<configuration>

<system.web>

<trace enabled="false" pageOutput="false" />

<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>

<compilation debug="false" />

</system.web>

</configuration>

 

Avoid exceptions

Exceptions are one of the largest hogs of resources, so you should always make it a point to avoid using system resources to handle useless exceptions.  Make certain that you never code by exception to avoid this big slowdown.

 

Caching!

One of the best ways to speed up an ASP application is to use ASP.net Cache API and Quick Page Caching, which are two powerful caching tools.  There is a lot involved here, and it's not simple, but there's no better way to speed things up on an ASP app.  Learning when and what to cache will make you a more effective ASP coder.

 

Make your deployment with Release Build

When you are ready to deploy to production, you must be sure to use Release Build mode and not the Debug Build you use when you are developing.  This makes a huge difference in terms of overhead and performance.  When you run a production application in debug mode, you are creating a lot of PDBs and generating timeouts.  Deploying in Release mode will result in a remarkable improvement in performance.

 

Stay away from server side validations

Whenever possible, you should always do validation on the client side.  Validation on the server side will only use valuable resources and cause needless back and forth communication between the client and server. 

 

Use all of these great tips to get better performance from all of your ASP apps.

ลงประกาศ 10 เมษายน, 2015

Happymarli

Proofreader, Editor, Writer and App Developer

Do you need a professional editor and writer to proofread your technical documents, thesis, novel, statement of purpose, personal statement, resume, cover letter, manuscript, essay, short story, textbook content, or articles? Do you want to make sure that your marketing material content is flawless and appealing to readers? I can do any of that! I am a professional editor (academic, copy, line/su...

บทความถัดไป

Tips for Maximizing jQuery