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

 
0
Kudos
 
0
Kudos

Now read this

C# Changes for the ASP.NET MVC Developer

C# 6 # Released Jul 20, 2015 Along with Roslyn Compiler, .NET 4.6, and Visual Studio 2015 Summary # C#6 focuses on streamlining common issues that require clumsy work-arounds that clutter the code. Null-conditional operator, string... Continue →