Blue Theme Orange Theme Green Theme Red Theme
 
Click Here for 3 Month Free of ASP.NET Hosting!
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » How do I » 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

Technologies: ASP.NET 1.0,Visual C# .NET
Total downloads :
Total page views :  18648
Rating :
 4.5/5
This article has been rated :  4 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
Become a Sponsor



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. 


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 Senior Software Engineer . He has been working with .NET technology since 2002 . Dinesh's background includes Master's in Computer Science and B.Sc. 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.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
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 | Delete | Modify | 
Re: Same article by Dinesh On June 7, 2006

All points are in details and how it affects performance

Reply | Email | Delete | Modify | 
Use HTML controls often by Hima Bindu 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 | Delete | 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 | Delete | Modify | 
Re: Re: Use HTML controls often by Hima Bindu 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved