简体   繁体   English

在DotNet Core中在运行时加载Razor cshtml页面

[英]Load Razor cshtml pages at runtime in DotNet Core

I would like to be able to drop in Razor based "Theme" _Layout.cshtml files at runtime in my current project, however I cannot find a way to tell the project not to pre-compile these files AND allow new files to be added (or existing files updated). 我希望能够在当前项目的运行时放入基于Razor的“ Theme” _Layout.cshtml文件,但是我无法找到一种方法来告诉项目不要预编译这些文件并允许添加新文件(或现有文件已更新)。

I have found, through the project settings to tell the project NOT to precompile views on Publish, which requires me to add the .cshtml files into the published package, but if they are updated at runtime, it requires a restart of the app for the changes to be noticed. 我发现通过项目设置告诉项目不要在Publish上预编译视图,这要求我将.cshtml文件添加到已发布的程序包中,但是如果它们在运行时更新,则需要重新启动应用程序才能使用发生变化。

Is this possible ? 这可能吗 ?

On the top of your .chtml page you will find that @layout =your layout page name. 在.chtml页面的顶部,您会发现@layout =您的布局页面名称。 Just remove the name and put null instead of that. 只需删除名称,然后输入null即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 WPF dotnet 核心项目中托管 Razor 页面和 API (AspnetCore) - Hosting Razor pages and API (AspnetCore) inside a WPF dotnet core project 如何预填充日期字段 dotnet core razor 页面? - How to pre-populate date field dotnet core razor pages? Core 2 Razor页面OnGetAsync加载静态文件 - Core 2 Razor Pages OnGetAsync Load Static File 如何在 dotnet core razor 页面中打开新创建的 Model Razor 页面 (3.1) - How to open a new created Model Razor Page in dotnet core razor pages (3.1) Asp.net Core Razor 页面无法从 csHTML 获取值到 C# - Asp.net Core Razor Pages Unable to fetch value from csHTML to C# .Net Core 5.0 .cshtml Razor 页面“if”阻止打开的 HTML 标签而不关闭它 - .Net Core 5.0 .cshtml Razor Pages "if" Block Open HTML Tag Without Closing It 如何在 ASP.NET 核心 Razor 页面中重用 _ViewImports.cshtml? - How to reuse _ViewImports.cshtml in ASP.NET Core Razor Pages? C# Dotnet Core 3.1 - 在运行时加载程序集 - C# Dotnet Core 3.1 - Load Assembly on Runtime 如何在 ASP.NET Core Razor Pages 项目的 _layout.cshtml 文件中使用 Razor 页面使用实体框架作为部分视图? - How to use Razor Page Using Entity Framework as a partial view in _layout.cshtml file in ASP.NET Core Razor Pages project? asp.net 核心 razor 页面 C# 中的页面文件夹中使用 Partial.cshtml 文件的 CS7036 错误消息 - CS7036 error message using a Partial.cshtml file in a Pages folder in asp.net core razor pages C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM