我已经在 app start 中注册了一个 PrecompilecMvcEngine 来预编译我的剃刀视图。构建包正确地排除了 ~/Views/ 目录中的所有 .cshtml 文件,但如果目录中存在视图,它会继续使用 .cshtml 文件,无论是否编译。例如,如果部署目录中存在视图 ~/Shared/Layout.cshtml,则始终使用该视图。如何确保从不使用物理视图?我有以下代码:[assembly: WebActivatorEx.PostApplicationStartMethod(typeof(SomeBaseNamespace.Views.RazorGeneratorMvcStart), "Start")]namespace SomeBaseNamespace.Views{ public static class RazorGeneratorMvcStart { public static void Start() { var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) { UsePhysicalViewsIfNewer = false // I would expect this to prevent the engine from using physical views. }; ViewEngines.Engines.Insert(0, engine); } }}
- 1 回答
- 0 关注
- 211 浏览
添加回答
举报
0/150
提交
取消