[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); ViewEngines.Engines.Add(engine); VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);