Asp.net mvc Razor模板,包含Mustach将在客户端上呈现的页面部分
我的页面包含将在客户端上呈现的部分 我遇到的问题是,razor不能像我期望的那样渲染零件。例如: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">
<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
帮助程序,它将正确解析相对于应用程序根目录的路径: