Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
6 Months Free & No Setup Fees ASP.NET Hosting!
Search :       Advanced Search »
Home » Programming Best Practices » Tips to improve the performance of ASP.Net Application

Tips to improve the performance of ASP.Net Application

This article features tips to improve the performance of ASP.Net Application

Page Views : 25240
Downloads : 0
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Team Foundation Server Hosting
Become a Sponsor
DevExpress Free UI Controls
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

1. Disable the Debug Mode or Set Debug ="false"

How it affect performance: By default this attribute is "true" when you create new application and is useful when you are developing the application. Debug = true means that pdb information to be inserted into file and this results a larger file size and it's performance issue. Before deployment you should set the following tag

 

<compilation defaultLanguage="Vb" debug="false">

2.  Set trace enabled="false"

 

How it affects performance: With help of tracing, we can track the application's and the sequences. Enabling tracing adds performance overhead and might expose private information, so it should be enabled only while an application is being actively analyzed. You can turn off tracing using
 

<Trace enabled="false"  - - - - -/>

3. While developing using Visual Studio.NET

 

When you set Configurations Option as "debug" mode, it creates pdb file to store the debug information hence before deploying the application set it to the "Release" mode.

 

You can set using

 

Select Menu Build -> Configuration Manager -- > Set the configuration option of project to the "Release" mode.

 

4. Disable the viewstate:

 

With the help of automatic state management feature, the server control is re-populate their values without writing any code. And it affects the performance. The always set EnableViewState = false when not requires.

For control
<asp: datagrid EnableViewState="false" datasource="..." runat="server"/>
For Page
<%@ Page EnableViewState="false" %>


5. Use Caching to improve the performance of your application.

OutputCaching enables your page to be cached for specific duration and can be made invalid based on various parameters that can be specified. The Cache exists for the duration you specify and until that time, the requests do not go to the server and are served from the Cache.

Do not assign cached items a short expiration. Items that expire quickly cause unnecessary turnover in the cache and frequently cause more work for cleanup code and the garbage collector. In case you have static as well as dynamic sections of your page, try to use Partial Caching (Fragment Caching) by breaking up your page into user controls and specify Caching for only those Controls which are more-or-less static.

6. Use appropriate Authentication Mechanism.


Following are the Authentication Modes.

  • None
  • Windows
  • Forms
  • Passport

7. Validate all Input received from the Users.

Validate all Input received from the users at client side to avoid the server round trip.

8. Use Finally Method to kill resources.

 

Always use the finally block to kill resources like closing database connection, closing files etc.

 

9. Always use the String builder to concatenate string

 

The memory representation of string is an array of characters, So on re-assigning the new array of Char is formed & the start address is changed. Thus keeping the old string in memory for garbage collector to be disposed. Hence application is slow down. Always use the string builder for concatenating string.

 

10. Enable the web gardening for multiprocessors computers:

 

The ASP.NET process model helps enable scalability on multiprocessor machines by distributing the work to several processes, one for each CPU, each with processor affinity set to its CPU. The technique is called Web gardening, and can dramatically improve the performance of some applications

 

11. Set Enlist="false" in connection string:

 

True indicates that the SQL Server connection Pooler automatically enlists the connection in the creation thread's current transaction context. That's why set enlist = false in connection string.

 

12. Avoid recursive functions / nested loops


13. Always set option strict to  "on"

 

14. Try to avoid Throwing Exceptions. 

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Dinesh Tawar
Dinesh L Tawar is a IT Analyst . He has been working with .NET technology since 2003 . Dinesh's background includes Master's in Computer Science. Contact details :tawar_dinesh@yahoo.com Url : dineshtawar.blogspot.com
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Team Foundation Server Hosting
Become a Sponsor
 Comments
Same article by Simple On May 17, 2006

Dinesh,

This site has the same article but it was posted there in March.  http://www.codeproject.com/useritems/NET_Tips_and_tricks.asp

.NET Performance Tips & Tricks
By
arunlala

 

Reply | Email | Modify 
Re: Same article by Dinesh On June 7, 2006

All points are in details and how it affects performance

Reply | Email | Modify 
Use HTML controls often by Hima On May 18, 2006

If we use HTML Controls instead of Server controls which in turn my enhance the performance

Go for server controls only when it's really necessary

Reply | Email | Modify 
Re: Use HTML controls often by Dinesh On June 8, 2006

 

hi hima,

   its nice to see your comment, the control is one entity for performance and other things also affects the performance. i think 40% is controls which we used in our application  and other 60% is the other factors ( like connection string , use of dataset, datareader , debug option etc.)

 

bye

Dinesh

Reply | Email | Modify 
Re: Re: Use HTML controls often by Hima On July 18, 2006


It's only one of the point to improve the performance of the application

It's(using HTML) will  not effect the 100% performance

Reply | Email | Modify 
Datagrid Update Problem by Ritu On July 20, 2006

hi

i m facing an unusual problem while developing asp.net application with vb.net as code behind. i m using tabstrip  with multipage control.their are 5 tabstrip objects having 5 different datagrids on each one of 5 pageviews. some validations are also done on each of them like textboxes within datagrids shud be integer ,while cliking add button no field sgud be empty in footer template etc.now the problem is

i m using editcommand column within datagrid. all buttons like edit,cancel,add delete are working except update button.when i click on update button neither this event {Public Sub DgrdTreasury_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DgrdTreasury.UpdateCommand}

and nor this{

Public Sub DgrdTreasury_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DgrdTreasury.ItemCommand}

fires means nothing happens.

what i guess is this is because when i click update button it starts validation of all the datagrids because they r placed on same page but in different pageviews.now if wat i guess  is true then how to set causevalidation as false in editcommand column as their is no builtin property like causevalidation. wat shud i do please suggest

 

 

Reply | Email | Modify 
Re: Datagrid Update Problem by Dinesh On August 10, 2006
hi ritu, i am sending some code just try this code and let me know its working or not. in html view of your page put this. datagrid_UpdateCommand - is the event name of your datagrid control try this and let me know . dinesh
Reply | Email | Modify 
Re: Datagrid Update Problem by ahmed On August 21, 2007

hi

befor months i was face same problem, i think the soultion was,

the tabstrip have event onchange tabstrip on code behid try to stop all other tabs casevalidation except the current tab programmaticly

the diffrancess between tabs known be checking the current tab index

sorry for i am arabic spoken

Reply | Email | Modify 
Report Creation by Amit On September 7, 2007
Your tips are nice, I want to confirm that which reporting tool should i use for reporting using asp.net (c#), sql server2000, Crystal report i think it Takes more time,resource. Suggest me
Reply | Email | Modify 
ASP.NET cache issues by fredrick On April 2, 2010
ASP.NET cache is good for improving performance but keep in mind its problems too. ASP.NET cache is a single point of failure, gives you data integrity problems in Web farms/garden. It has cache size limit, too.  If you want to avoid these problems, the only option is to use third-party distributed cache. There are a few available for free like <a href="http://www.alachisoft.com/download.html> NCache Express </a>.

One of the good things i found in this software is that it requires no code change in ASP.NET at all.
Reply | Email | Modify 
6 Months Free & No Setup Fees ASP.NET Hosting!
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.