Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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
Asp.net mvc Razor模板,包含Mustach将在客户端上呈现的页面部分_Asp.net Mvc_Asp.net Mvc 4_Razor 2 - Fatal编程技术网

Asp.net mvc Razor模板,包含Mustach将在客户端上呈现的页面部分

Asp.net mvc Razor模板,包含Mustach将在客户端上呈现的页面部分,asp.net-mvc,asp.net-mvc-4,razor-2,Asp.net Mvc,Asp.net Mvc 4,Razor 2,我的页面包含将在客户端上呈现的部分 我遇到的问题是,razor不能像我期望的那样渲染零件。例如: <script type="x-tmpl-mustache" id="filterTemplate"> <img id="showFilter" src="~/Content/Image/arrow.png" /> </script> <script type="x-tmpl-mustache" id="filterTemplate">

我的页面包含将在客户端上呈现的部分

我遇到的问题是,razor不能像我期望的那样渲染零件。例如:

<script type="x-tmpl-mustache" id="filterTemplate">
        <img id="showFilter" src="~/Content/Image/arrow.png" />
</script>
<script type="x-tmpl-mustache" id="filterTemplate">
        <img id="showFilter" src='@Url.Content("~/Content/Image/arrow.png")' />
</script>

不会呈现
~
符号,只有当我将img放置在脚本标记之外时,它才会按预期执行


这是在不同的应用程序路径中发布的,因此我需要razor找出什么是
~
,并将其替换为应用程序路径。

您应该使用
@Url.Content
帮助程序,它将正确解析相对于应用程序根目录的路径: