我有这个标记:
@using (Html.BeginRouteForm("Default", new { controller = "Home", action = "Form" }, FormMethod.Post, new { @ID="FormId", @Name="FormId"}))
{
<span>...</span>
<div class="clearFloats"><!-- ---></div>
<span>...</span>
}
自从转移到 Razor 2、MVC 4 我现在得到错误:
-
The using block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
如果我删除 <div class="clearFloats"><!-- ---></div>
代码,一切正常。我知道解决方案是为某种不同的构造更改这些 float 清除 div,但为什么它现在中断了?
最佳答案
临时解决方案是包装 <!-- -->
与 @Html.Raw("<!-- -->")
这似乎消除了错误。
编辑:实际上,您的示例中的问题是结尾的三个破折号 --->
在关闭评论标签上。删除其中一个,它可以正常工作。
关于asp.net-mvc - HTML 标记破坏 Razor 使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12055516/