title: How do I force compilation of ASP.NET MVC views?
body: <p>I have a Windows Azure web role that contains a web site using ASP.NET MVC. When an HTTP request arrives and a page is first loaded the view (.aspx or .cshtml) is compiled and that takes some time and so the first time a page is served it takes notable longer than later serving the same page.</p>
  
  <p>I've enabled <code>&lt;MvcBuildViews&gt;</code> (described <a href="https://stackoverflow.com/a/542944/57428">in this answer</a>) to enforce compile-time validation of views, but that doesn't seem to have any effect on their compilation when the site is deployed and running.</p>
  
  <p>Azure web roles have so-called startup tasks and also a special <code>OnStart()</code> method where I can place whatever warmup code, so once I know what to do adding that into the role is not a problem.</p>
  
  <p>Is there a way to force compilation of all views?</p>