【发布时间】:2011-06-22 13:49:28
【问题描述】:
我有一个评论表单,我试图在其中呈现指向 HTML 标签内 Markdown 引用的 HTML 链接。我尝试在我的视图模型中添加指向DisplayName 属性的链接:
[DisplayName("Comment (you can format comments with <a href=\"http://daringfireball.net/projects/markdown/syntax\">Markdown</a>)")]
public string Body { get; set; }
这会导致以下显示:
我也尝试直接在视图中添加标签:
@Html.LabelFor(x => x.Comment.Body, "Comment (you can format comments with <a href=\"http://daringfireball.net/projects/markdown/syntax\">Markdown</a>)")
但结果是可以理解的。
我意识到这是因为 MVC 是 HTMLEncoding 安全输出,但是有没有办法按标签关闭它,或者在这种情况下我只需要在我的视图中手动写出一个 HTML 标签?
【问题讨论】:
标签: asp.net-mvc-3 rendering label razor data-annotations