Slow Razor Views in MVC? Make Sure You're Not In Debug Mode

13 May 2016

A short and sweet tip for today - I was investigating a page which I thought had some performance issues. My initial assumption was the backend controller, but a combination of SQL Profiler and Glimpse (which is super great and easy to use) showed me that the real bottleneck was ViewResult.ExecuteResult().

While someone on the internet suggested it might be a bunch of Url.Actions() causing issues, the real culprit turned out to be not running my code in Release mode. In Debug mode, none of the Razor view lookups are cached, and everything is extremely slow. Adjusting my web.config to turn debug mode off took the page load time from 18 seconds down to 1 second.

So make sure you keep this in mind if you're seeing extremely slow performance when rendering MVC Razor Views! There's a few other performance tips listed here that's worth a quick look too.

Tags: MVC, Razor, ViewResult, performance, debugging, Glimpse

Add a Comment

No Comments