I have tried two things. One is pre-compiling my ASP.NET MVC 3 project using aspnet_compiler, and the other is using RazorGenerator in the project to allow the views to be compiled. Using both methods, I still see that pages in my site are having to compile on the first access. I see csc.exe running on the server when they are first accessed and it doesn't happen the next time. Why are these pre-compiling steps not preventing this and thus letting me have faster first time access?
Asked
Active
Viewed 1,582 times
1
-
1Take a look to this thread: http://stackoverflow.com/questions/7387123/how-to-warm-up-an-asp-net-mvc-application-on-iis-7-5 – vtortola Dec 13 '12 at 20:23
1 Answers
1
Pre-compiling an application won't improve the first request startup time because there are still many things that need to happen when the first request arrives:
- The Application_Start method executes
- Controllers and Views location are retrieved and cached for subsequent requests
- ...
You could use the AutoStart feature
of IIS 7.5 and ASP.NET 4.0 if you want to preload an application in memory when the web server starts. This way the application will be hot and waiting for the first request.

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
-
But what if you want to deploy a live website and minimize the initial waiting time? Will this feature work immediately after a site is started in IIS? – Roger Far Dec 13 '12 at 20:32
-
1Yes, it will work because IIS will autostart the site as soon as it is deployed, not as soon as the first request arrives and thus avoiding the first request slowness. – Darin Dimitrov Dec 13 '12 at 20:44
-
It makes sense that it has to do other stuff and that can take time. I'm specifically wondering why csc.exe is called though and not just for the very first request, for the first request to each page. Shouldn't I be able to pre-compile whatever it is trying to compile? Especially since it seems to happen for each view. There seems to be zero performance benefit from using the pre-compilers. – user1902139 Dec 13 '12 at 21:30
-
The benefit from precompiling an ASP.NET application is that it will load faster compared to if it was not precompiled. In a non-precompiled ASP.NET application you deploy all the C# source files to the web server as well and they need to be compiled dynamically at the first request which could slow things even more. When you precompile your application only the views need to be dynamically compiled on the first request. It's how view engines work in ASP.NET and there's not much you could do about it. – Darin Dimitrov Dec 13 '12 at 21:45