ASP.Net MVC Performance

In this post, we will discuss how can we increase the performance of website that uses ASP.NET MVC.

  1. Remove Unused view engines

    protected void Application_Start() 
    ViewEngines.Engines.Add(new RazorViewEngine()); 
  2. Deploying Production Code in Release Mode Make sure your production application always runs in release mode in the web.config.

    <compilation debug=”false”></compilation>
    <configuration> <system.web> 
    <deployment retail=”true”></deployment> </system.web> </configuration>
  3. Use OutputCacheAttribute When Appropriate MVC will not do any View Look-up Caching if you are running your application in Debug Mode.

    [OutputCache(VaryByParam = "none", Duration = 3600)]
    public ActionResult Categories() 
    return View(new Categories()); 
  4. Use HTTP Compression Add gzip (HTTP compression) and static cache (images, CSS, …) in your web.config.

    <system.webserver><urlcompression dodynamiccompression=”true” 
    dostaticcompression=”true” dynamiccompressionbeforecache=”true”></urlcompression>
  5. Avoid passing null models to views

  6. Remove unused HTTP Modules

  7. Put repetitive code inside your PartialViews

  8. Add an Expires or a Cache-Control Header

    <clientCache cacheControlMode="UseExpires"
    httpExpires="Mon, 06 May 2013 00:00:00 GMT" />
  9. Avoid Empty Image src

  10. No 404s

We hope this helps someone else out!

Posted in ASP.Net on Sep 28, 2015

Scroll To Top