How to enable precompiled razor views (.cshtml) in ASP.NET 5

If you want your .cshtml to be precompiled before the first request hits, you need to enable it manually.

This increases time needed for compilation, however the compilation process still takes not much time at all.


Create a class that inherits from RazorPreCompileModule and override the  EnablePreCompilation method.
Disabling generation for symbols is optional:



Reference it in your Startup.cs:



Mahmut Jomaa is a Software Engineer from Germany.

Currently he attends university to gain more knowledge in Computer Science.

Security code Refresh