https://github.com/StackExchange/StackExchange.Precompilation:
我们在已安装StackExchange.Precompilation的单独库中有一些共享视图。我们必须加载这些视图以及正常的Web项目视图。我们在两个项目中都从NuGet安装了最新版本的StackExchange.Precompilation。我正在进行这样的装配加载:
// Register precompiled view engine
ViewEngines.Engines.Clear();
List<Assembly> viewAssemblies = new List<Assembly> { typeof(HomeController).Assembly };
viewAssemblies.AddRange(AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.ToLower().Contains(".web")));
Log.Debug().Message("Looking for views in: {0}", string.Join(", ", viewAssemblies.Select(a => a.FullName))).Write();
ViewEngines.Engines.Add(new PrecompiledViewEngine(viewAssemblies.ToArray()));
在网络项目中,我们以正常方式返回视图:return View("Index");
使用PrecompiledViewEngine
时,我们在尝试呈现这样的相对名称时会出错:
The view 'Index' or its master was not found or no view engine supports the searched locations.
The following locations were searched:
~/util/Views/Example/Index.cshtml
~/util/Views/Shared/Index.cshtml
util
是IIS中应用程序的别名。我们没有任何注册的区域。
当我从GitHub复制PrecompiledViewEngine
课程时,工作!我错过了一些可以通过NuGet分发版本的东西吗?
答案 0 :(得分:1)
复制代码结果不起作用。我当然一直在尝试别的东西,使其适用于特定情况。
问题实际上是StackExchange.Precompilation中的一个错误。我在那里创建了一个问题:https://github.com/StackExchange/StackExchange.Precompilation/issues/12