This project is read-only.

IVirtualPathFactory registration causes BuildManager call for every _Layout Page

May 16, 2013 at 11:03 AM
Edited May 16, 2013 at 11:11 AM
I set my layout inside my .cshtml pages like this:
    Layout = "~/Views/Shared/_LayoutMicroPedi.cshtml";
With the default RazorGeneratorMvcStart file this code is executed (to make sure _ViewStart works properly):


However this causes calls to IVirtualPathFactory.CreateInstance for every page that uses a Layout (no other virtualpaths seem to ever reach this method). The default setting for PreemptPhysicalFiles is false so this means the following code is executed for every page with a layout.
  return BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(WebPageRenderingBase));
That seems to kind of defeat the whole caching mechanism.

I'm also pretty confused when I'm supposed to use PreemptPhysicalFiles vs. UsePhysicalViewsIfNewer.

I'm not even using WebStart (or multiple DLLs) so I just removed this 'RegisterVirtualPathFactory' method.

Would be interested to hear somebody elses thoughts on this.
May 16, 2013 at 5:26 PM
There's some documentation of what the two properties mean here -

I'm not entirely sure what you mean by caching mechanism. The code path that we have is a near clone of of the Razor ViewEngine in System.Web.Mvc.