如何在这个Html.ActionLink中插入HTML字符?

use*_*993 5 html css c# asp.net-mvc twitter-bootstrap

我正在使用以下代码生成此代码:

<p>@Html.ActionLink("Read", "Index", "News", null, new { @class = "btn btn-default" })</p>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

但我想创建一个看起来像这样的按钮(使用HTML字符&raquo;): 在此输入图像描述

但是,当我执行以下操作时:

<p>@Html.ActionLink("Read &raquo;", "Index", "News", null, new { @class = "btn btn-default" })</p>
Run Code Online (Sandbox Code Playgroud)

我明白了:

在此输入图像描述

我该如何解决?

Pol*_*ton 9

这里给出的其他解决方案.但是,万一你想知道,如果你没有键盘上的特殊字符该怎么办,这里有:

你可以使用

<a href='@Url.Action("Index", "News")' class="btn btn-default">Read &raquo;</a>
Run Code Online (Sandbox Code Playgroud)

要么

@Html.ActionLink(HttpUtility.HtmlDecode("Read &raquo;"), "Index", "News", null, new { @class = "btn btn-default" })
Run Code Online (Sandbox Code Playgroud)


Mat*_*oSp 2

文本将由 ActionLink() 实现进行编码,因此您不需要这样做。只需在字符串中使用该字符即可。