We have started using MiniProfiler and it is showing that sometimes, particularly when we hit F5 when running in Visual Studio that the first 3 - 5 calls to an action are very slow before any of our code executes as the picture below shows, it always seems to be approximately 5, these are actions which return an image but as MiniProfiler is showing all the time is occurring before any of our code even executes, if I comment out the image that is taking 2050ms then another that is taking 0.5ms simply takes this long. We have set debug=false in web.config which has made no difference.
We are using both the ProfilingActionFilter and ProfilingViewEngine but is there another way to profile what is happening here and trying to work out?
EDIT: We are also using AutoFac, is it possible this is the cause, I'm trying to find a way of profiling everything so I can see exactly where this is happening.
EDIT: OK So I added my own ControllerFactory which profiles and a route constraint, as the new image below shows all the time is happening before the route constraint or controller is even created, before the Application_BeginRequest. I'm at a complete loss as to what is taking so much time. Looking at this link of the MVC pipeline what can be left?
http://blog.stevensanderson.com/blogfiles/2007/ASPNET-MVC-Pipeline/ASP.NET%20MVC%20Pipeline.pdf