Our web application contains dozens of partial views, some of them are children of others. We noticed that the application comes slowly at the first boot, it takes from 0.5 to 1 second to initialize each view that it calls for the first time. I kept track of time and found that this:
Html.RenderPartial("~/Full/Relative/Path/To/View.cshtml", null);
may take about 1 second, even if the view is completely empty. At the same time it is:
var view = ViewEngines.Engines.FindPartialView( ViewContext.Controller.ControllerContext, "~/Full/Relative/Path/To/View.cshtml");
takes 1 millisecond, so no time is spent searching for a file.
Questions:
1. Is it normal for a view compiler to take so long?
2. Is there any other way to quickly make the first call, but not have a representation precompiled with the directive in csproj?
ps: it is strange that the same views loaded faster at the beginning of application development.
source share