SlideShare a Scribd company logo
o improve the performance of an ASP.Net application you need to
optimize your front-end UI (user interface) code as well as the back-
end database. You can also think of the following tips as a brief best
practices guide for the ASP.net performance optimization.
http://www.hartmannsoftware.com/
T
Use Stored Procedures. A Stored Procedure has an execution plan hence it
always performs faster than T-SQL. Logic separation, Low network bandwidth
consumption, improved data security and integrity are some of the added
benefits of using a stored procedure.
http://www.hartmannsoftware.com/
Write efficient queries. A few tips:
• If needed, de-normalize your database design a bit. Too many joins can
make your query expensive.
• Avoid the use of cursor.
• Return only the Rows and Columns needed.
• Fully qualify database objects.
http://www.hartmannsoftware.com/
ViewState is a bandwidth guzzler...
To make its handling simple, always remember that for almost all practical
purposes you can disable it for most of the controls (exception being
DropDownLists, Listboxes and TreeViews).
For TextBoxes, ViewState needs to be enabled only if you are using
Text_Changed event. In a page if you are absolutely sure that you don’t
require it all then it’s better to disable it at Page level. Add the following to
your Page directive <%@ Page EnableViewState="false" %>
http://www.hartmannsoftware.com/
SSL (Secure Socket Layer i.e. URLs beginning with https) is in fashion but
avoid it and use it only for pages that transmit sensitive information like
password, credit card number or any other information you deem sensitive. If
you are using SSL for a page make sure the page contains minimal graphics.
A web page deployed under simple http performs much faster than an https
page.
http://www.hartmannsoftware.com/
If you care about Scalability avoid using session state. Performance is not an
issue while you are using one web server but be prepared for the worst if you
are scaling out to multiple servers. At the same time, if you are sure that
your application will never require multiple servers (or you’ll always have a
limited number of users) session state is your best bait and performs faster
than any other state management options.
http://www.hartmannsoftware.com/
Use image sprites. Yes, this tip is more relevant to the UI designer than the
developer. Sprites reduce the number of server requests and hence your
page loads faster. W3Schools define an image sprite as a collection of
images put into a single image. So, you are downloading a single optimized
image with a single request rather than downloading multiple images with
multiple requests. With CSS, you can define the coordinates to show just the
part of the image you need
http://www.hartmannsoftware.com/
Add script references at the bottom of the page. Script
references mainly JavaScript are common in ASP.Net applications, and if they
are referred at the top the asynchronous downloads halt when a script
reference is reached, severely impacting the page performance.
http://www.hartmannsoftware.com/
For applications with huge number of users spread around
the globe, use CDN (Content Delivery Network) for hosting images and
scripts. This reduces load on your server and your users experiences a quick
response from your application.
http://www.hartmannsoftware.com/
Include the values of height and width attribute in tag.
Yes, this is another one for UI designers! With a well-defined explicit height
and width attribute space can be allocated for the image before it is
downloaded i.e. quick page load.
http://www.hartmannsoftware.com/
Validate form entries on the client using JavaScript. This
helps to avoid unnecessary round trips to the server making your application
quick and responsive. It leads to a better user experience.
http://www.hartmannsoftware.com/
Never run production ASP.NET applications with debug=”true” enabled. By
default it is enabled true in your web.config file. At production server it must
be deployed with. There’s a detailed article devoted to this web.config debug
attribute from none other than Scott Guthrie (an ASP.Net authority and a big
shot at Microsoft Corp.) - See more at:
http://www.hartmannsoftware.com/Blog/Articles_from_Software_Fans/10-
Quick-Tips-to-Boost-Your-ASP-Net-Application-
Performance#sthash.oSHFUBZK.dpuf
Asp.Net Tips

More Related Content

Asp.Net Tips

  • 1. o improve the performance of an ASP.Net application you need to optimize your front-end UI (user interface) code as well as the back- end database. You can also think of the following tips as a brief best practices guide for the ASP.net performance optimization. http://www.hartmannsoftware.com/ T
  • 2. Use Stored Procedures. A Stored Procedure has an execution plan hence it always performs faster than T-SQL. Logic separation, Low network bandwidth consumption, improved data security and integrity are some of the added benefits of using a stored procedure. http://www.hartmannsoftware.com/
  • 3. Write efficient queries. A few tips: • If needed, de-normalize your database design a bit. Too many joins can make your query expensive. • Avoid the use of cursor. • Return only the Rows and Columns needed. • Fully qualify database objects. http://www.hartmannsoftware.com/
  • 4. ViewState is a bandwidth guzzler... To make its handling simple, always remember that for almost all practical purposes you can disable it for most of the controls (exception being DropDownLists, Listboxes and TreeViews). For TextBoxes, ViewState needs to be enabled only if you are using Text_Changed event. In a page if you are absolutely sure that you don’t require it all then it’s better to disable it at Page level. Add the following to your Page directive <%@ Page EnableViewState="false" %> http://www.hartmannsoftware.com/
  • 5. SSL (Secure Socket Layer i.e. URLs beginning with https) is in fashion but avoid it and use it only for pages that transmit sensitive information like password, credit card number or any other information you deem sensitive. If you are using SSL for a page make sure the page contains minimal graphics. A web page deployed under simple http performs much faster than an https page. http://www.hartmannsoftware.com/
  • 6. If you care about Scalability avoid using session state. Performance is not an issue while you are using one web server but be prepared for the worst if you are scaling out to multiple servers. At the same time, if you are sure that your application will never require multiple servers (or you’ll always have a limited number of users) session state is your best bait and performs faster than any other state management options. http://www.hartmannsoftware.com/
  • 7. Use image sprites. Yes, this tip is more relevant to the UI designer than the developer. Sprites reduce the number of server requests and hence your page loads faster. W3Schools define an image sprite as a collection of images put into a single image. So, you are downloading a single optimized image with a single request rather than downloading multiple images with multiple requests. With CSS, you can define the coordinates to show just the part of the image you need http://www.hartmannsoftware.com/
  • 8. Add script references at the bottom of the page. Script references mainly JavaScript are common in ASP.Net applications, and if they are referred at the top the asynchronous downloads halt when a script reference is reached, severely impacting the page performance. http://www.hartmannsoftware.com/
  • 9. For applications with huge number of users spread around the globe, use CDN (Content Delivery Network) for hosting images and scripts. This reduces load on your server and your users experiences a quick response from your application. http://www.hartmannsoftware.com/
  • 10. Include the values of height and width attribute in tag. Yes, this is another one for UI designers! With a well-defined explicit height and width attribute space can be allocated for the image before it is downloaded i.e. quick page load. http://www.hartmannsoftware.com/
  • 11. Validate form entries on the client using JavaScript. This helps to avoid unnecessary round trips to the server making your application quick and responsive. It leads to a better user experience. http://www.hartmannsoftware.com/
  • 12. Never run production ASP.NET applications with debug=”true” enabled. By default it is enabled true in your web.config file. At production server it must be deployed with. There’s a detailed article devoted to this web.config debug attribute from none other than Scott Guthrie (an ASP.Net authority and a big shot at Microsoft Corp.) - See more at: http://www.hartmannsoftware.com/Blog/Articles_from_Software_Fans/10- Quick-Tips-to-Boost-Your-ASP-Net-Application- Performance#sthash.oSHFUBZK.dpuf