SlideShare a Scribd company logo
Simple steps to improve
performance of ASP.NET Application
                    Brij Bhushan Mishra
Agenda
   Introduction
   Improving ASP.NET Website Performance
   Development Tips
   Some more development tips
   Configuration Tips
   Some more Configurations Tips
   Conclusion
About Me
   Brij Bhushan Mishra
   Microsoft ASP.NET/IIS MVP
   Former CodeProject MVP
   Blogger/Author/Speaker



   http://brijbhushan.net
   @brij_bhushan
   brij.mishra@outlook.com
ASP.NET Pages
   Keep Page size small
       Include all the referred files (CSS, JS, images)
       Move CSS/Javascript to separate files
       Remove HTML comments, Extra spaces
       Ensure all are cached at Clients

   Use isPostback judicially
ASP.NET Pages
   Check your PageSource and see the __VIEWSTATE
    variable
   Minimize ViewState – Turn off if not using
   ASP.NET 4 : Enable ViewState at Control Level
       Controls got a new property ViewStateMode
           Enabled
           Disabled
           Inherit




                                      Demo
ASP.NET Pages
   Add Caching Wherever appropriate
     Output
     Fragment
     Cache API

   Avoid using Application variable, use cache
    instead. Cache is robust and provides a wide
    list of options for intelligently managing
    application level data
Paging at Database level
   Most of us do paging at Application level.
   It could be hazardous if you have large amount of
    data
   Optimize the paging based on your requirement and
    data
Lazy Loading is not a Silver Bullet
   Lazyloading is good but not every time.
   Blindly enabling lazy loading and using it could
    degrade the performance. You might end up hitting
    database again and again that could be easily
    loaded in single database hit.
Use Ajax calls judiciously
   Avoid UpdatePanels
   Prefer ClientSide Ajax (True Ajax)




                                  Demo
Use SQL profiler to check the hits
   Run the SQL profiler when access your page.
   You might be unknowingly hitting database several
    times. It’s very common using any ORM tool like
    Entity Framework
   This is one of the main reason of slow applications
Use using to avoid Memory Leaks
   If a Type implements IDisposable then it is a right
    candidate to use with using statement.
   While leaving the using block, Dispose method will
    be itself called.
Fixed the Width and Height <img />
   If you know the width and height of an image.
    Provide it before hand else your browser will keep
    guessing until it get downloaded.
   Page loads faster because browser assigns the
    required areas to image before it gets downloaded
Understand Loops
   Best loop For
   Next Foreach (IEnumerable)
   Linq loops
String, StringBuilder, String.join
   For static strings, use string.
   For string manipulation, StringBuilder should be
    used.
       The StringBuilder class starts with a default initial capacity
        of 16
       If you know the max size that will be taken care by
        stringbuilder, create you object like
        StringBuilder sb = new StringBuilder(2000);
   StringBuilder is not best in every case
   If you have already set of fixed set of string to
    concatenate, use string.join
Image Sprites
   Have lots of images and paying an HTTPRequest for
    each of them on your page?
   ASP.NET provides a solution that is available via
    Nuget Package
   Run the Nuget package - Install-Package
    AspNetSprites-WebFormsControl




                                Demo
Bundling and Minification
   This feature is introduced in ASP.NET 4.5.
   This enables to bundle all the script files into single
    file while loading at the browser. Minification is also
    applied to these files so that it’s size get reduced
   Prior to ASP.NET 4.5, people used to write their own
    custom code or some third party plugins to achieve
    it.




                                    Demo
Script reference at bottom of the page
   Reference the scripts files at bottom of the page.
   Problem with scripts that It blocks parallel download
HTTPCompression
   Turn on HTTPCompression for static and dynamic
    content (for dynamic content, give time to decide)
   It reduces the size significantly of HTML content
   For, IIS7 and IIS 8, go to IIS Manager -> Feature
    View of the website . Click on Compression and
    enable.
       Only compress which file size is larger. (more than few
        bytes)
   IIS 6 – Can be done via running some coomand, I
    have written a post on it.
    http://brijbhushan.net/2010/10/17/how-to-enable-
    httpcompression-at-iis6/
Review the files that you are downloading
each page
   ASP.NET project by default provides many scripts
    and other file with default project template. Remove
    them if you are not using it.
   Also, have another check while shipping the project
Remove HTTP Modules
   ASP.NET Page request processing
             Request            Response



                       HTTPModule 1



                       HTTPModule 2



                       HTTPModule 3

                            .
                            .
                            .

                       HTTPModule n




                       HTTP Handler
Remove HTTP Modules contd.
   There are many HTTPModules by default enabled.
   Remove all the modules which is not used




                               Demo
Use startMode Attribute
   Whenever a site is updated, IIS recompiles the
    application at first request. It may take long on the
    first request.
   Also, most of the time, we load lot of data in cache
    etc at first request.
   This attribute is part of IIS and is available
    applicationHost.config at
    C:WindowsSystem32inetsrvconfigapplicationHost.config
   It is set at application pool level as
   <applicationPools>
      <add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0"
          startMode="AlwaysRunning" />
   </applicationPools>
Conclusion
   Questions?




   Thank You

More Related Content

PPTX
Adobe Meetup AEM Architecture Sydney 2015
PPTX
Adobe CQ5 for Developers - Introduction
PDF
Architetture Serverless con SQL Server e Azure Functions
PPTX
EVOLVE'16 | Deploy | Abhishek Dwevedi | Understanding a Typical AEM Deployment
PPTX
Asp.net MVC training session
PPTX
Entity Framework Code First Migrations
PPTX
Introduction to ASP.NET
PDF
Tips and Tricks For Faster Asp.NET and MVC Applications
Adobe Meetup AEM Architecture Sydney 2015
Adobe CQ5 for Developers - Introduction
Architetture Serverless con SQL Server e Azure Functions
EVOLVE'16 | Deploy | Abhishek Dwevedi | Understanding a Typical AEM Deployment
Asp.net MVC training session
Entity Framework Code First Migrations
Introduction to ASP.NET
Tips and Tricks For Faster Asp.NET and MVC Applications

What's hot (20)

PPT
Dependency Injection in Silverlight
PPTX
Building an enterprise app in silverlight 4 and NHibernate
PPT
Ajax & ASP.NET 2
PPTX
Aem best practices
PPTX
ASP.NET MVC 5 - EF 6 - VS2015
PPTX
ASP.NET 5 Overview for Apex Systems
PPTX
10 performance and scalability secrets of ASP.NET websites
PDF
Isomorphic JavaScript: #DevBeat Master Class
PPTX
Azure Templates for Consistent Deployment
PPTX
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
PDF
Introducing CQ 5.1
PPTX
Scaling asp.net websites to millions of users
PDF
Securing applications
PPTX
Microsoft Fakes, Unit Testing the (almost) Untestable Code
PPT
ColdFusion framework comparison
PDF
Setup ColdFusion application using fusebox mvc architecture
PPTX
ASP.NET MVC Performance
PPTX
Getting started with MVC 5 and Visual Studio 2013
PDF
Progressive EPiServer Development
PPT
Require JS
Dependency Injection in Silverlight
Building an enterprise app in silverlight 4 and NHibernate
Ajax & ASP.NET 2
Aem best practices
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET 5 Overview for Apex Systems
10 performance and scalability secrets of ASP.NET websites
Isomorphic JavaScript: #DevBeat Master Class
Azure Templates for Consistent Deployment
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Introducing CQ 5.1
Scaling asp.net websites to millions of users
Securing applications
Microsoft Fakes, Unit Testing the (almost) Untestable Code
ColdFusion framework comparison
Setup ColdFusion application using fusebox mvc architecture
ASP.NET MVC Performance
Getting started with MVC 5 and Visual Studio 2013
Progressive EPiServer Development
Require JS
Ad

Viewers also liked (7)

PPTX
Introduction to XAML and its features
PPTX
SQL Server2012 Enhancements
PPTX
Working with Azure Resource Manager Templates
PPTX
Mobile Services for Windows Azure
PPTX
F12 debugging in Ms edge
PPTX
AMicrosoft azure hyper v recovery manager overview
PPTX
Stream Analytics Service in Azure
Introduction to XAML and its features
SQL Server2012 Enhancements
Working with Azure Resource Manager Templates
Mobile Services for Windows Azure
F12 debugging in Ms edge
AMicrosoft azure hyper v recovery manager overview
Stream Analytics Service in Azure
Ad

Similar to Asp.net performance (20)

PPSX
Flex 4.5 jeyasekar
PPTX
Improving Drupal Performances
PPT
Asp.net performance secrets
PDF
Drupal performance and scalability
PPT
IIS 6.0 and asp.net
PPTX
Performace optimization (increase website speed)
PPT
Fun With Http Handlers - Miguel A. Castro
PPTX
Drupal Frontend Performance and Scalability
PPT
Google App Engine for Java
DOCX
Beginners introduction to asp.net
PDF
Introduction to asp
PDF
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
PPT
Developing Java Web Applications
PDF
Advanced Asp.Net Concepts And Constructs
PPTX
Presentation Tier optimizations
PDF
DrupalCampLA 2011 - Drupal frontend-optimizing
PDF
Asp.net Web Development.pdf
PPS
14 asp.net session20
PPTX
ASP.NET Presentation
Flex 4.5 jeyasekar
Improving Drupal Performances
Asp.net performance secrets
Drupal performance and scalability
IIS 6.0 and asp.net
Performace optimization (increase website speed)
Fun With Http Handlers - Miguel A. Castro
Drupal Frontend Performance and Scalability
Google App Engine for Java
Beginners introduction to asp.net
Introduction to asp
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Developing Java Web Applications
Advanced Asp.Net Concepts And Constructs
Presentation Tier optimizations
DrupalCampLA 2011 - Drupal frontend-optimizing
Asp.net Web Development.pdf
14 asp.net session20
ASP.NET Presentation

More from Abhishek Sur (20)

PPTX
Azure servicefabric
PPT
Building a bot with an intent
PPTX
Code review
PPTX
C# 7.0 Hacks and Features
PPTX
Angular JS, A dive to concepts
PPTX
Designing azure compute and storage infrastructure
PPTX
Service bus to build Bridges
PPTX
Windows azure pack overview
PPTX
Di api di server b1 ws
PPTX
Integrating cortana with wp8 app
PPTX
Dev days Visual Studio 2012 Enhancements
PPTX
Hidden Facts of .NET Language Gems
PPTX
ASP.NET 4.5 webforms
PPT
Entity framework 4.0
PPTX
Why do I Love C#?
PPTX
Overview of Azure and Cloud Computing
PPTX
The Magic of WPF & MVVM
PPT
Asynchronous handlers in asp.net
PPTX
Memory Management & Garbage Collection
PPTX
How to become a Super Productive Developer
Azure servicefabric
Building a bot with an intent
Code review
C# 7.0 Hacks and Features
Angular JS, A dive to concepts
Designing azure compute and storage infrastructure
Service bus to build Bridges
Windows azure pack overview
Di api di server b1 ws
Integrating cortana with wp8 app
Dev days Visual Studio 2012 Enhancements
Hidden Facts of .NET Language Gems
ASP.NET 4.5 webforms
Entity framework 4.0
Why do I Love C#?
Overview of Azure and Cloud Computing
The Magic of WPF & MVVM
Asynchronous handlers in asp.net
Memory Management & Garbage Collection
How to become a Super Productive Developer

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Big Data Technologies - Introduction.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation theory and applications.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation theory and applications.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
MIND Revenue Release Quarter 2 2025 Press Release
NewMind AI Weekly Chronicles - August'25-Week II
SOPHOS-XG Firewall Administrator PPT.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Tartificialntelligence_presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Network Security Unit 5.pdf for BCA BBA.

Asp.net performance

  • 1. Simple steps to improve performance of ASP.NET Application Brij Bhushan Mishra
  • 2. Agenda  Introduction  Improving ASP.NET Website Performance  Development Tips  Some more development tips  Configuration Tips  Some more Configurations Tips  Conclusion
  • 3. About Me  Brij Bhushan Mishra  Microsoft ASP.NET/IIS MVP  Former CodeProject MVP  Blogger/Author/Speaker  http://brijbhushan.net  @brij_bhushan  [email protected]
  • 4. ASP.NET Pages  Keep Page size small  Include all the referred files (CSS, JS, images)  Move CSS/Javascript to separate files  Remove HTML comments, Extra spaces  Ensure all are cached at Clients  Use isPostback judicially
  • 5. ASP.NET Pages  Check your PageSource and see the __VIEWSTATE variable  Minimize ViewState – Turn off if not using  ASP.NET 4 : Enable ViewState at Control Level  Controls got a new property ViewStateMode  Enabled  Disabled  Inherit Demo
  • 6. ASP.NET Pages  Add Caching Wherever appropriate  Output  Fragment  Cache API  Avoid using Application variable, use cache instead. Cache is robust and provides a wide list of options for intelligently managing application level data
  • 7. Paging at Database level  Most of us do paging at Application level.  It could be hazardous if you have large amount of data  Optimize the paging based on your requirement and data
  • 8. Lazy Loading is not a Silver Bullet  Lazyloading is good but not every time.  Blindly enabling lazy loading and using it could degrade the performance. You might end up hitting database again and again that could be easily loaded in single database hit.
  • 9. Use Ajax calls judiciously  Avoid UpdatePanels  Prefer ClientSide Ajax (True Ajax) Demo
  • 10. Use SQL profiler to check the hits  Run the SQL profiler when access your page.  You might be unknowingly hitting database several times. It’s very common using any ORM tool like Entity Framework  This is one of the main reason of slow applications
  • 11. Use using to avoid Memory Leaks  If a Type implements IDisposable then it is a right candidate to use with using statement.  While leaving the using block, Dispose method will be itself called.
  • 12. Fixed the Width and Height <img />  If you know the width and height of an image. Provide it before hand else your browser will keep guessing until it get downloaded.  Page loads faster because browser assigns the required areas to image before it gets downloaded
  • 13. Understand Loops  Best loop For  Next Foreach (IEnumerable)  Linq loops
  • 14. String, StringBuilder, String.join  For static strings, use string.  For string manipulation, StringBuilder should be used.  The StringBuilder class starts with a default initial capacity of 16  If you know the max size that will be taken care by stringbuilder, create you object like StringBuilder sb = new StringBuilder(2000);  StringBuilder is not best in every case  If you have already set of fixed set of string to concatenate, use string.join
  • 15. Image Sprites  Have lots of images and paying an HTTPRequest for each of them on your page?  ASP.NET provides a solution that is available via Nuget Package  Run the Nuget package - Install-Package AspNetSprites-WebFormsControl Demo
  • 16. Bundling and Minification  This feature is introduced in ASP.NET 4.5.  This enables to bundle all the script files into single file while loading at the browser. Minification is also applied to these files so that it’s size get reduced  Prior to ASP.NET 4.5, people used to write their own custom code or some third party plugins to achieve it. Demo
  • 17. Script reference at bottom of the page  Reference the scripts files at bottom of the page.  Problem with scripts that It blocks parallel download
  • 18. HTTPCompression  Turn on HTTPCompression for static and dynamic content (for dynamic content, give time to decide)  It reduces the size significantly of HTML content  For, IIS7 and IIS 8, go to IIS Manager -> Feature View of the website . Click on Compression and enable.  Only compress which file size is larger. (more than few bytes)  IIS 6 – Can be done via running some coomand, I have written a post on it. http://brijbhushan.net/2010/10/17/how-to-enable- httpcompression-at-iis6/
  • 19. Review the files that you are downloading each page  ASP.NET project by default provides many scripts and other file with default project template. Remove them if you are not using it.  Also, have another check while shipping the project
  • 20. Remove HTTP Modules  ASP.NET Page request processing Request Response HTTPModule 1 HTTPModule 2 HTTPModule 3 . . . HTTPModule n HTTP Handler
  • 21. Remove HTTP Modules contd.  There are many HTTPModules by default enabled.  Remove all the modules which is not used Demo
  • 22. Use startMode Attribute  Whenever a site is updated, IIS recompiles the application at first request. It may take long on the first request.  Also, most of the time, we load lot of data in cache etc at first request.  This attribute is part of IIS and is available applicationHost.config at C:WindowsSystem32inetsrvconfigapplicationHost.config  It is set at application pool level as  <applicationPools>  <add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />  </applicationPools>
  • 23. Conclusion  Questions?  Thank You