Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在MVC视图中包含预编译的内容_C#_Html_Asp.net Mvc_Asp.net Core - Fatal编程技术网

C# 在MVC视图中包含预编译的内容

C# 在MVC视图中包含预编译的内容,c#,html,asp.net-mvc,asp.net-core,C#,Html,Asp.net Mvc,Asp.net Core,我有一些预编译的html内容,我想包括在我的视图中,如: @*View Start*@ Some precompiled html Some view content Some precompiled html Some view content Some precompiled html @*View End*@ 我已经想到了一些方法,但是每种方法都有一些我不想使用的缺点。以下是我的想法: 尽管这些html代码是使用固定内容预编译的,但它们可能会不时更改(比如每周),因此不能

我有一些预编译的html内容,我想包括在我的视图中,如:

@*View Start*@ 

Some precompiled html

Some view content

Some precompiled html

Some view content

Some precompiled html

@*View End*@
我已经想到了一些方法,但是每种方法都有一些我不想使用的缺点。以下是我的想法:

  • 尽管这些html代码是使用固定内容预编译的,但它们可能会不时更改(比如每周),因此不能包含在视图中
  • 它们的大小相当大,所以我不认为将它们放在数据库中是明智的(会增加数据库大小和数据带宽)
  • 将它们放在html文件中,并使用类似于
    @File.ReadAllText(“page customized head.html”)
    的C#函数将它们写入视图中,这样做速度会很慢,并且会使硬盘比应该的更繁忙
我想知道是否有人能提出更好的解决方案或改进上述解决方案的方法

编辑: 我已经搁置了像ajax这样的解决方案,因为在这种情况下不适合我的设计。在@Hadee的评论之后,我注意到我的描述不完整,所以我添加了更多的描述

这些内容文件对于不同用户的不同页面是唯一的,因为用户可以自定义css、js。添加-编辑删除html元素。因此,每个用户可能有几个页面,每个页面可能有几个不同的“预编译”部分

由于这些内容可能是页面的标题部分,可能包含css、js(以下内容可能依赖它)ajax不适合在这里使用


至于部分视图,我看不出它们和将内容写入html文件之间有什么不同。实际上,我认为html文件和
@file.ReadAllText(“page customized head.html”)
会更快,因为与
.cshtml
不同,它不需要编译。

为什么不尝试局部查看?还是ajax调用的html结果?@Hadee我想我的问题不完整。我编辑了我的问题。感谢您的评论,您可以选择
MVC区域