This project is read-only.

[This blog post has more details on this feature, so you may want to start there]

1. Precompile MVC views by setting the host to MvcView

@* Generator : MvcView *@

2. Runtime components are required to serve precompiled files from an assembly. Add a Reference to the Microsoft.Web.PrecompiledMvcView assembly.

3. Register instances of the PrecompiledMvcViewEngine in a PreApplicationStart method of the precompiled assembly or Global.asax of the MVC application you need to. The second option allows you to control the precompiled MVC better whereas the first one makes it easy to distribute your assembly.

Use the following snippet to register the engine.

    var engine = new PrecompiledMvcEngine(typeof(PreApplicationStartCode).Assembly);



Last edited Jul 22, 2011 at 7:53 PM by davidebbo, version 2


lencharest Jul 2, 2014 at 10:45 PM 
blaiseliu: I think the name of the assemby has been changed to RazorGenerator.Mvc, and you can get it by installing the RazorGenerator.Mvc package via NuGet.

blaiseliu Jun 10, 2014 at 7:28 PM 
#2: Add a Reference to the Microsoft.Web.PrecompiledMvcView assembly.
Sorry but where is this assembly?

Orlangur Oct 12, 2011 at 11:31 AM 
MVC uses assembly-qualified type name of the view engine to disambiguate view cache entries from different view engines. So it's not possible to have more than one PrecompiledMvcEngine object (as when you have precompiled views in more than one assembly). The problem can be solved by creating a different derived class from PrecompiledMvcEngine for each assembly. Or by creating a single generic derived class parameterized with some type from the assembly.