使用asp.net核心发布视图

编程入门 行业动态 更新时间:2024-10-11 07:36:07
本文介绍了使用asp核心发布视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在asp core 2.0项目中,我想强制发布View,因为我在运行时需要它们. 有任何线索吗?

In an asp core 2.0 project, I would like to force the publish of Views because I need them at runtime. Any clues?

推荐答案

编辑your.csproj文件,并将PreserveCompilationContext添加为true,将MvcRazorCompileOnPublish添加为false

edit your.csproj file and add PreserveCompilationContext as true and MvcRazorCompileOnPublish as false

<PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> <PreserveCompilationContext>true</PreserveCompilationContext> <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish> </PropertyGroup>

然后视图将包含在发布中

then views will be included in publish

从2.1版开始,无法使用 Razor类库,并且无需嵌入视图,而是可以对其进行预编译. Web应用程序中的本地视图仍然可以覆盖类库中的视图.在新方案中,您将删除PreserveCompilationContext和MvcRazorCompileOnPublish设置,而仅使用默认值.这样,应用程序中的所有视图都将被预编译,并且发布输出中将不包含.cshtml文件.

As of version 2.1 it is not possible to use Razor Class Libraries, and instead of embedding views they can be pre-compiled. Local views in the web app can still override views in the class library. In the new scenario you would remove the PreserveCompilationContext and MvcRazorCompileOnPublish settings and just use the default values. This way all views in the application will be pre-compiled and no .cshtml files will be included in the publish output.

更多推荐

使用asp.net核心发布视图

本文发布于:2023-11-16 01:56:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1599952.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   核心   asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!