Why do my asp.net views take so long to render?

I’ve optimized my database queries with indexes and am caching output for 10 minutes at a time, but occasionally I have to recalculate the page, and it’s taking way longer than I like. Tools like firebug only show that the request spent a long time waiting on the server. What I really need is a tool to help me locate the bottleneck.

Enter Glimpse, an open-source tool to analyze load times end-to-end for C# asp.net applications. It times everything from javascript, web requests, controller actions, view rendering, database queries, ajax calls, and more.

2016-08-09 07_23_06-Window.png

This image shows that the total time to render the page was 478ms. Of that, 351ms was spent server-side, and 198ms of that was on rendering the view. That means not the database access, but compiling the cshtml with embedded C# at runtime.

How to reduce that render time? Precompile the views at build time!

Now that the views are precompiled, our page render time has dropped to 208ms, with only 72ms spent server side. At 208ms, page loads feel almost instant, which only happens when we have a cache miss once every ten minutes.
2016-08-09 07_30_02-Window.png


Now read this

Visual Studio Changes for the ASP.NET MVC Developer

Visual Studio 2015 - Jul 20, 2015 # What strikes me most about VS2015 is how eagerly javascript/html/css frameworks and build tools are being incorporated and supported by Visual Studio. These tools change so rapidly that I think it will... Continue →